Class: CfnFlow::StackParams
- Inherits:
-
Hash
- Object
- Hash
- CfnFlow::StackParams
- Defined in:
- lib/cfn_flow/stack_params.rb
Overview
Extend hash with some special behavior to generate the style of hash aws-sdk expects
Class Method Summary collapse
Instance Method Summary collapse
- #add_tag(hash) ⇒ Object
- #with_expanded_parameters ⇒ Object
- #with_expanded_tags ⇒ Object
- #with_expanded_template_body ⇒ Object
- #with_symbolized_keys ⇒ Object
Class Method Details
.expanded(hash) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/cfn_flow/stack_params.rb', line 6 def self.(hash) self[hash]. with_symbolized_keys. . . end |
Instance Method Details
#add_tag(hash) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/cfn_flow/stack_params.rb', line 41 def add_tag(hash) = hash.map do |k,v| {key: k, value: v } end = (self[:tags] || []) + self.merge(tags: ) end |
#with_expanded_parameters ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/cfn_flow/stack_params.rb', line 21 def return self unless self[:parameters].is_a? Hash = self[:parameters].map do |key,value| { parameter_key: key, parameter_value: fetch_value(key, value) } end self.merge(parameters: ) end |
#with_expanded_tags ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/cfn_flow/stack_params.rb', line 31 def return self unless self[:tags].is_a? Hash = self[:tags].map do |key, value| {key: key, value: value} end self.merge(tags: ) end |
#with_expanded_template_body ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/cfn_flow/stack_params.rb', line 49 def return self unless self[:template_body].is_a? String body = CfnFlow::Template.new(self[:template_body]).to_json self.merge(template_body: body) rescue CfnFlow::Template::Error # Do nothing self end |
#with_symbolized_keys ⇒ Object
14 15 16 17 18 19 |
# File 'lib/cfn_flow/stack_params.rb', line 14 def with_symbolized_keys self.inject(StackParams.new) do |accum, pair| key, value = pair accum.merge(key.to_sym => value) end end |