Class: Arpa::DataMappers::Base

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/arpa/data_mappers/base.rb

Instance Method Summary collapse

Instance Method Details

#map_to_entity(record, options = {}) ⇒ Object



13
14
15
16
17
18
# File 'lib/arpa/data_mappers/base.rb', line 13

def map_to_entity(record, options = {})
  options[:map_association_to] ||= :map_to_entity
  attrs_to_entity = self.class._attrs_to_entity
  attributes      = attributes_from(record, attrs_to_entity, options)
  self.class._entity_class.new(attributes)
end

#map_to_record(entity, options = {}) ⇒ Object



6
7
8
9
10
11
# File 'lib/arpa/data_mappers/base.rb', line 6

def map_to_record(entity, options = {})
  options[:map_association_to] ||= :map_to_record
  attrs_to_record = self.class._attrs_to_record
  attributes      = attributes_from(entity, attrs_to_record, options)
  self.class._repository_class.new(attributes)
end