Class: Humidifier::Props::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/humidifier/props/base.rb

Overview

Superclass for all CFN properties

Constant Summary collapse

WHITELIST =

The list of classes that are valid beyond the normal values for each prop

[Fn, Ref].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, spec = {}, substructs = {}) ⇒ Base

Returns a new instance of Base.



13
14
15
16
17
18
# File 'lib/humidifier/props/base.rb', line 13

def initialize(key, spec = {}, substructs = {})
  @key  = key
  @name = Utils.underscore(key)
  @spec = spec
  after_initialize(substructs) if respond_to?(:after_initialize, true)
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



11
12
13
# File 'lib/humidifier/props/base.rb', line 11

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/humidifier/props/base.rb', line 11

def name
  @name
end

#specObject (readonly)

Returns the value of attribute spec.



11
12
13
# File 'lib/humidifier/props/base.rb', line 11

def spec
  @spec
end

#substructsObject (readonly)

Returns the value of attribute substructs.



11
12
13
# File 'lib/humidifier/props/base.rb', line 11

def substructs
  @substructs
end

Instance Method Details

#documentationObject

the link to the AWS docs



21
22
23
# File 'lib/humidifier/props/base.rb', line 21

def documentation
  spec['Documentation']
end

#required?Boolean

true if this property is required by the resource

Returns:

  • (Boolean)


26
27
28
# File 'lib/humidifier/props/base.rb', line 26

def required?
  spec['Required']
end

#to_cf(value) ⇒ Object

CFN stack syntax



31
32
33
# File 'lib/humidifier/props/base.rb', line 31

def to_cf(value)
  [key, Serializer.dump(value)]
end

#update_typeObject

the type of update that occurs when this property is updated on its associated resource



37
38
39
# File 'lib/humidifier/props/base.rb', line 37

def update_type
  spec['UpdateType']
end

#whitelisted_value?(value) ⇒ Boolean

true if the given value is of a type contained in the whitelist

Returns:

  • (Boolean)


42
43
44
# File 'lib/humidifier/props/base.rb', line 42

def whitelisted_value?(value)
  WHITELIST.any? { |clazz| value.is_a?(clazz) }
end