Class: Jets::Stack::Parameter

Inherits:
Object
  • Object
show all
Includes:
Definition
Defined in:
lib/jets/stack/parameter.rb,
lib/jets/stack/parameter/dsl.rb

Defined Under Namespace

Modules: Dsl

Instance Method Summary collapse

Methods included from Definition

#camelize, #initialize, #register

Instance Method Details

#add_required(attributes) ⇒ Object



31
32
33
34
35
# File 'lib/jets/stack/parameter.rb', line 31

def add_required(attributes)
  properties = attributes.values.first
  properties[:type] ||= 'String'
  attributes
end

#standarize(definition) ⇒ Object

Type is the only required property: amzn.to/2x8W5aD



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/jets/stack/parameter.rb', line 14

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
    logical_id, properties = first, second
    { logical_id => properties }
  elsif (definition.size == 2 && second.is_a?(String)) || # short form
        definition.size == 1
    logical_id = first
    properties = second.is_a?(String) ? { default: second } : {}
    { logical_id => properties }
  else # I dont know what form
    raise "Invalid form provided. definition #{definition.inspect}"
  end
end

#templateObject



9
10
11
# File 'lib/jets/stack/parameter.rb', line 9

def template
  camelize(add_required(standarize(@definition)))
end