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.
11 12 13 14 15 16 |
# File 'lib/humidifier/props/base.rb', line 11 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.
9 10 11 |
# File 'lib/humidifier/props/base.rb', line 9 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/humidifier/props/base.rb', line 9 def name @name end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
9 10 11 |
# File 'lib/humidifier/props/base.rb', line 9 def spec @spec end |
#substructs ⇒ Object (readonly)
Returns the value of attribute substructs.
9 10 11 |
# File 'lib/humidifier/props/base.rb', line 9 def substructs @substructs end |
Instance Method Details
#documentation ⇒ Object
the link to the AWS docs
19 20 21 |
# File 'lib/humidifier/props/base.rb', line 19 def documentation spec['Documentation'] end |
#required? ⇒ Boolean
true if this property is required by the resource
24 25 26 |
# File 'lib/humidifier/props/base.rb', line 24 def required? spec['Required'] end |
#to_cf(value) ⇒ Object
CFN stack syntax
29 30 31 |
# File 'lib/humidifier/props/base.rb', line 29 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
34 35 36 |
# File 'lib/humidifier/props/base.rb', line 34 def update_type spec['UpdateType'] end |
#whitelisted_value?(value) ⇒ Boolean
true if the given value is of a type contained in the whitelist
39 40 41 |
# File 'lib/humidifier/props/base.rb', line 39 def whitelisted_value?(value) WHITELIST.any? { |clazz| value.is_a?(clazz) } end |