Class: CfMapping

Inherits:
Object
  • Object
show all
Defined in:
lib/cf_factory/base/cf_mapping.rb

Instance Method Summary collapse

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

#generateObject



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_regionObject



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