Class: Lono::Template::Strategy::Dsl::Builder::Section::Output

Inherits:
Base
  • Object
show all
Defined in:
lib/lono/template/strategy/dsl/builder/section/output.rb

Constant Summary

Constants included from Fn

Fn::FUNCTIONS

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Lono::Template::Strategy::Dsl::Builder::Stringify

#stringify!

Methods included from Common::Helpers

#extract_scripts, #scripts_name, #scripts_s3_path, #setting

Methods included from Fn

#conditional_ref, define_methods, #fn, #fn_id, #get_att, #get_azs, included, #join, #ref, #sub

Constructor Details

This class inherits a constructor from Lono::Template::Strategy::Dsl::Builder::Section::Base

Instance Method Details

#standarize(definition) ⇒ Object

Value is the only required property: amzn.to/2xbhmk3



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/lono/template/strategy/dsl/builder/section/output.rb', line 12

def standarize(definition)
  first, second, _ = definition
  if definition.size == 1 && first.is_a?(Hash) # long form
    first # pass through
  elsif definition.size == 2 && second.is_a?(Hash) # medium form
    if second.key?(:value) || second.key?("Value")
      logical_id, properties = first, second
    else
      logical_id = first
      properties = {Value: second}
    end
    { logical_id => properties }
  elsif definition.size == 2 && (second.is_a?(String) || second.nil?) # short form
    logical_id = first
    properties = second.is_a?(String) ? { Value: second } : {}
    { logical_id => properties }
  elsif definition.size == 1
    logical_id = first.to_s
    properties = { Value: ref(logical_id) }
    { logical_id => properties }
  else # I dont know what form
    raise "Invalid form provided. definition #{definition.inspect}"
  end
end

#templateObject



7
8
9
# File 'lib/lono/template/strategy/dsl/builder/section/output.rb', line 7

def template
  camelize(standarize(@definition))
end