Module: Humidifier::Props

Defined in:
lib/humidifier/props.rb,
lib/humidifier/props/base.rb,
lib/humidifier/props/map_prop.rb,
lib/humidifier/props/json_prop.rb,
lib/humidifier/props/list_prop.rb,
lib/humidifier/props/double_prop.rb,
lib/humidifier/props/string_prop.rb,
lib/humidifier/props/boolean_prop.rb,
lib/humidifier/props/integer_prop.rb,
lib/humidifier/props/structure_prop.rb,
lib/humidifier/props/timestamp_prop.rb

Overview

Container for property of CFN resources

Defined Under Namespace

Classes: Base, BooleanProp, DoubleProp, IntegerProp, JsonProp, ListProp, MapProp, StringProp, StructureProp, TimestampProp

Class Method Summary collapse

Class Method Details

.from(key, spec, substructs = {}) ⇒ Object

builds the appropriate prop object from the given spec line



6
7
8
9
10
11
12
# File 'lib/humidifier/props.rb', line 6

def from(key, spec, substructs = {})
  case spec['Type']
  when 'List' then ListProp.new(key, spec, substructs)
  when 'Map'  then MapProp.new(key, spec, substructs)
  else             singular_from(key, spec, substructs)
  end
end

.singular_from(key, spec, substructs) ⇒ Object

builds a prop that is not a List or Map type PrimitiveType is one of Boolean, Double, Integer, Json, String, or Timestamp



16
17
18
19
20
21
22
23
24
25
# File 'lib/humidifier/props.rb', line 16

def singular_from(key, spec, substructs)
  primitive = spec['PrimitiveItemType'] || spec['PrimitiveType']

  if primitive
    primitive = 'Integer' if primitive == 'Long'
    const_get(:"#{primitive}Prop").new(key, spec)
  else
    StructureProp.new(key, spec, substructs)
  end
end