Class: CfFactory::CfMapping
- Inherits:
-
Object
- Object
- CfFactory::CfMapping
- Defined in:
- lib/cf_factory/base/cf_mapping.rb
Instance Method Summary collapse
- #generate ⇒ Object
- #generate_ref(key) ⇒ Object
-
#initialize(name, target, from_to_hash) ⇒ CfMapping
constructor
A new instance of CfMapping.
- #map_from_region ⇒ Object
Constructor Details
#initialize(name, target, from_to_hash) ⇒ CfMapping
Returns a new instance of CfMapping.
3 4 5 6 7 |
# File 'lib/cf_factory/base/cf_mapping.rb', line 3 def initialize(name, target, from_to_hash) @name = name @target = target @from_to_hash = from_to_hash end |
Instance Method Details
#generate ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cf_factory/base/cf_mapping.rb', line 9 def generate @result = "" @result += " \"#{@name}\" : {\n" @from_to_hash.keys.each() {|key| value = @from_to_hash[key] @result += " \"#{key}\"\t : { \"#{@target}\" : \"#{value}\" },\n" } @result = @result.chomp.chomp(",") @result += "\n }," end |
#generate_ref(key) ⇒ Object
20 21 22 |
# File 'lib/cf_factory/base/cf_mapping.rb', line 20 def generate_ref(key) "{\"Fn::FindInMap\" : [ \"#{@name}\", #{CfHelper.generate_ref(key)}, \"#{@target}\" ]}" end |
#map_from_region ⇒ Object
24 25 26 |
# File 'lib/cf_factory/base/cf_mapping.rb', line 24 def map_from_region() "{\"Fn::FindInMap\" : [ \"#{@name}\", \"#{CfHelper.ref_current_region()}\", \"#{@target}\" ]}" end |