Class: Stacker::Stack::Parameter
- Inherits:
-
Object
- Object
- Stacker::Stack::Parameter
- Extended by:
- Memoist
- Defined in:
- lib/stacker/stack/parameter.rb
Overview
A Parameter represents a stack parameter. A parameter can be either a literal value (e.g. a string, number, or array) or a reference, otherwise known as a dependency. References parameter values are represented as hashes with a single key indicating the reference type. There is one exception to this rule; references to stack outputs are expressed as hashes with two keys, “Stack” and “Output”.
Instance Attribute Summary collapse
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(parameter) ⇒ Object
- #dependencies ⇒ Object
- #dependency? ⇒ Boolean
-
#initialize(value, region) ⇒ Parameter
constructor
A new instance of Parameter.
- #resolved ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#region ⇒ Object (readonly)
Returns the value of attribute region.
18 19 20 |
# File 'lib/stacker/stack/parameter.rb', line 18 def region @region end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
18 19 20 |
# File 'lib/stacker/stack/parameter.rb', line 18 def value @value end |
Instance Method Details
#==(parameter) ⇒ Object
66 67 68 |
# File 'lib/stacker/stack/parameter.rb', line 66 def ==(parameter) parameter.value == value && parameter.region == region end |
#dependencies ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/stacker/stack/parameter.rb', line 33 def dependencies if dependency? [ to_s ] elsif value.is_a?(Array) value.map(&:dependencies).flatten else [ ] end end |
#dependency? ⇒ Boolean
29 30 31 |
# File 'lib/stacker/stack/parameter.rb', line 29 def dependency? value.is_a?(Hash) end |
#resolved ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/stacker/stack/parameter.rb', line 43 def resolved if dependency? begin resolver.resolve rescue => err raise ParameterResolutionError.new value, err end elsif value.is_a?(Array) value.map(&:resolved).join ',' else value end end |
#to_s ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/stacker/stack/parameter.rb', line 58 def to_s if dependency? value.values.map(&:to_s).sort.join('.') else value.to_s end end |