Class: Humidifier::Props::Prop
- Inherits:
-
Object
- Object
- Humidifier::Props::Prop
- Defined in:
- lib/humidifier/props.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.
Class Method Summary collapse
Instance Method Summary collapse
-
#documentation ⇒ Object
the link to the AWS docs.
-
#initialize(key, spec = {}) ⇒ Prop
constructor
A new instance of Prop.
-
#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.
- #valid?(value) ⇒ Boolean
Constructor Details
#initialize(key, spec = {}) ⇒ Prop
Returns a new instance of Prop.
13 14 15 16 17 |
# File 'lib/humidifier/props.rb', line 13 def initialize(key, spec = {}) @key = key @name = key.underscore @spec = spec end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/humidifier/props.rb', line 11 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/humidifier/props.rb', line 11 def name @name end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
11 12 13 |
# File 'lib/humidifier/props.rb', line 11 def spec @spec end |
Class Method Details
.allow_type(*types) ⇒ Object
49 50 51 52 |
# File 'lib/humidifier/props.rb', line 49 def allow_type(*types) allowed_types @allowed_types += types end |
Instance Method Details
#documentation ⇒ Object
the link to the AWS docs
20 21 22 |
# File 'lib/humidifier/props.rb', line 20 def documentation spec["Documentation"] end |
#required? ⇒ Boolean
true if this property is required by the resource
25 26 27 |
# File 'lib/humidifier/props.rb', line 25 def required? spec["Required"] end |
#to_cf(value) ⇒ Object
CFN stack syntax
30 31 32 |
# File 'lib/humidifier/props.rb', line 30 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
36 37 38 |
# File 'lib/humidifier/props.rb', line 36 def update_type spec["UpdateType"] end |
#valid?(value) ⇒ Boolean
40 41 42 |
# File 'lib/humidifier/props.rb', line 40 def valid?(value) self.class.allowed_types.any? { |type| value.is_a?(type) } end |