Class: Loqate::Mappers::GenericMapper Private
- Inherits:
-
Object
- Object
- Loqate::Mappers::GenericMapper
- Defined in:
- lib/loqate/mappers/generic_mapper.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Transforms arrays of hashes into concrete instances of classes.
Instance Method Summary collapse
-
#map(items, object_class) ⇒ Object
private
Creates objects from an API response.
-
#map_one(item, object_class) ⇒ Object
private
Creates a single object from an API response.
Instance Method Details
#map(items, object_class) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates objects from an API response. The objects will be an instance of object_class
.
17 18 19 |
# File 'lib/loqate/mappers/generic_mapper.rb', line 17 def map(items, object_class) items.map { |item| map_one(item, object_class) } end |
#map_one(item, object_class) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a single object from an API response. The object will be an instance of object_class
.
28 29 30 31 |
# File 'lib/loqate/mappers/generic_mapper.rb', line 28 def map_one(item, object_class) attributes = item.transform_keys { |attribute| Util.underscore(attribute) } object_class.new(attributes) end |