Module: Lono::Template::Strategy::Dsl::Builder::Helpers::TagsHelper
- Included in:
- Lono::Template::Strategy::Dsl::Builder::Helpers
- Defined in:
- lib/lono/template/strategy/dsl/builder/helpers/tags_helper.rb
Instance Method Summary collapse
Instance Method Details
#dimensions(hash) ⇒ Object
32 33 34 35 36 37 |
# 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) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 = {}) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/lono/template/strategy/dsl/builder/helpers/tags_helper.rb', line 3 def (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 |