Class: CfMapping
- Inherits:
-
Object
- Object
- 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.
2 3 4 5 6 |
# File 'lib/cf_factory/base/cf_mapping.rb', line 2 def initialize(name, target, from_to_hash) @name = name @target = target @from_to_hash = from_to_hash end |
Instance Method Details
#generate ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cf_factory/base/cf_mapping.rb', line 8 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
19 20 21 |
# File 'lib/cf_factory/base/cf_mapping.rb', line 19 def generate_ref(key) "{\"Fn::FindInMap\" : [ \"#{@name}\", #{CfHelper.generate_ref(key)}, \"#{@target}\" ]}" end |
#map_from_region ⇒ Object
23 24 25 |
# File 'lib/cf_factory/base/cf_mapping.rb', line 23 def map_from_region() "{\"Fn::FindInMap\" : [ \"#{@name}\", \"#{CfHelper.ref_current_region()}\", \"#{@target}\" ]}" end |