Class: ApiMapper::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/api_mapper/mapper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attributes(*attributes) ⇒ Object



9
10
11
# File 'lib/api_mapper/mapper.rb', line 9

def attributes(*attributes)
  @attributes ||= Array(@attributes) + attributes
end

.entity(klass) ⇒ Object



13
14
15
# File 'lib/api_mapper/mapper.rb', line 13

def entity(klass)
  @entity = klass
end

.relationship(name, mapper = nil) ⇒ Object



17
18
19
20
# File 'lib/api_mapper/mapper.rb', line 17

def relationship(name, mapper = nil)
  @relationships ||= []
  @relationships << Relationship.new(name, mapper)
end

.transformationObject



22
23
24
# File 'lib/api_mapper/mapper.rb', line 22

def transformation
  mapping >> factory
end

Instance Method Details

#call(origin) ⇒ Object



4
5
6
# File 'lib/api_mapper/mapper.rb', line 4

def call(origin)
   self.class.transformation.call(origin)
end