Class: AcceptableApi::Mapper

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

Instance Method Summary collapse

Constructor Details

#initialize(from, to, &map_block) ⇒ Mapper

Returns a new instance of Mapper.



13
14
15
16
17
# File 'lib/acceptable_api/mapper.rb', line 13

def initialize from, to, &map_block
  self.from = from
  self.to = to
  self.map_block = map_block
end

Instance Method Details

#execute(resource, request) ⇒ Object



27
28
29
# File 'lib/acceptable_api/mapper.rb', line 27

def execute resource, request
  map_block.call resource, request
end

#from?(desired) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/acceptable_api/mapper.rb', line 19

def from? desired
  from == desired
end

#missing?Boolean

Returns:

  • (Boolean)


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

def missing?
  false
end

#to?(desired) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/acceptable_api/mapper.rb', line 23

def to? desired
  to == desired
end