Class: Seiso::ImportMaster::Mappers::MasterItemMapper
- Inherits:
-
Object
- Object
- Seiso::ImportMaster::Mappers::MasterItemMapper
- Defined in:
- lib/seiso/import_master/mappers/master_item_mapper.rb
Overview
Maps the data master format to the Seiso API format.
- Author
-
Willie Wheeler
- Copyright
-
Copyright © 2014-2015 Expedia, Inc.
- License
-
Apache 2.0
Instance Method Summary collapse
-
#initialize ⇒ MasterItemMapper
constructor
A new instance of MasterItemMapper.
-
#map_all(type, items) ⇒ Object
Maps a list of items.
-
#map_one(type, item) ⇒ Object
Maps a single item.
Constructor Details
#initialize ⇒ MasterItemMapper
Returns a new instance of MasterItemMapper.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/seiso/import_master/mappers/master_item_mapper.rb', line 12 def initialize @mappers = { 'data-centers' => data_center_mapper, 'doc-links' => doc_link_mapper, 'environments' => environment_mapper, 'health-statuses' => health_status_mapper, 'infrastructure-providers' => infrastructure_provider_mapper, 'load-balancers' => load_balancer_mapper, 'machines' => machine_mapper, 'regions' => region_mapper, 'rotation-statuses' => rotation_status_mapper, 'service-groups' => service_group_mapper, 'service-types' => service_type_mapper, 'status-types' => status_type_mapper } end |
Instance Method Details
#map_all(type, items) ⇒ Object
Maps a list of items.
-
type: Item type
-
items: Item list
32 33 34 35 36 37 |
# File 'lib/seiso/import_master/mappers/master_item_mapper.rb', line 32 def map_all(type, items) mapper = mapper_for type result = [] items.each { |i| result << mapper.call(i) } result end |
#map_one(type, item) ⇒ Object
Maps a single item.
-
type: Item type
-
item: Item
42 43 44 |
# File 'lib/seiso/import_master/mappers/master_item_mapper.rb', line 42 def map_one(type, item) mapper_for(type).call item end |