Class: Humidifier::Props::Base
- Inherits:
-
Object
- Object
- Humidifier::Props::Base
- Defined in:
- lib/humidifier/props/base.rb
Overview
Superclass for all CFN properties
Direct Known Subclasses
BooleanProp, DoubleProp, IntegerProp, JsonProp, ListProp, MapProp, StringProp, StructureProp, TimestampProp
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
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
-
#substructs ⇒ Object
readonly
Returns the value of attribute substructs.
Instance Method Summary collapse
-
#documentation ⇒ Object
the link to the AWS docs.
-
#initialize(key, spec = {}, substructs = {}) ⇒ Base
constructor
A new instance of Base.
-
#required? ⇒ Boolean
true if this property is required by the resource.
-
#to_cf(value) ⇒ Object
CFN stack syntax.
-
#update_type ⇒ Object
the type of update that occurs when this property is updated on its associated resource.
-
#whitelisted_value?(value) ⇒ Boolean
true if the given value is of a type contained in the whitelist.
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
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/humidifier/props/base.rb', line 11 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/humidifier/props/base.rb', line 11 def name @name end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
11 12 13 |
# File 'lib/humidifier/props/base.rb', line 11 def spec @spec end |
#substructs ⇒ Object (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
#documentation ⇒ Object
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
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_type ⇒ Object
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
42 43 44 |
# File 'lib/humidifier/props/base.rb', line 42 def whitelisted_value?(value) WHITELIST.any? { |clazz| value.is_a?(clazz) } end |