Class: CloudBuilder::Mappings

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cloud_builder/mappings.rb

Instance Method Summary collapse

Constructor Details

#initializeMappings

Returns a new instance of Mappings.



8
9
10
# File 'lib/cloud_builder/mappings.rb', line 8

def initialize
  @maps = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(map_name, values) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/cloud_builder/mappings.rb', line 20

def method_missing(map_name, values)
  if @maps.has_key?(map_name.to_s)
    raise NameError('mapping %s is already defined' % map_name.to_s)
  end
  
  @maps[map_name.to_s] = values
end

Instance Method Details

#to_json_dataObject



12
13
14
15
16
17
18
# File 'lib/cloud_builder/mappings.rb', line 12

def to_json_data
  json = {}
  @maps.each do |key, value|
    json[DSL.format(key)] = value
  end
  json
end