module Lono::Template::Strategy::Dsl::Builder::Helpers::TagsHelper

Public Instance Methods

dimensions(hash) click to toggle source
# File lib/lono/template/strategy/dsl/builder/helpers/tags_helper.rb, line 32
def dimensions(hash)
  tag_list(hash).map { |h|
    h[:Name] = h.delete(:Key) || h.delete(:key)
    h
  }
end
tag_list(hash) click to toggle source
# File lib/lono/template/strategy/dsl/builder/helpers/tags_helper.rb, line 11
def tag_list(hash)
  raise "tags hash cannot be empty" if hash == nil

  if hash.is_a?(Array)
    hash = hash.inject({}) do |h,i|
      i.symbolize_keys!
      h[i[:Key]] = i[:Value]
      h
    end
    return tag_list(hash) # recursive call tag_list to normalized the argument with a Hash
  end

  propagate = hash[:PropagateAtLaunch] # special treatment
  list = hash.map do |k,v|
    h = {Key: k.to_s, Value: v}
    h[:PropagateAtLaunch] = propagate unless propagate.nil?
    h
  end
  list.reject { |h| h[:Key] == "PropagateAtLaunch" }
end
tags(hash={}) click to toggle source
# File lib/lono/template/strategy/dsl/builder/helpers/tags_helper.rb, line 3
def tags(hash={})
  if hash.empty?
    tag_list(@tags) if @tags # when hash is empty, use @tags variable. If not set then return nil
  else
    tag_list(hash)
  end
end