Class: AcceptableApi::Mapper
- Inherits:
-
Object
- Object
- AcceptableApi::Mapper
- Defined in:
- lib/acceptable_api/mapper.rb
Instance Method Summary collapse
- #execute(resource, request) ⇒ Object
- #from?(desired) ⇒ Boolean
-
#initialize(from, to, &map_block) ⇒ Mapper
constructor
A new instance of Mapper.
- #missing? ⇒ Boolean
- #to?(desired) ⇒ Boolean
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
19 20 21 |
# File 'lib/acceptable_api/mapper.rb', line 19 def from? desired from == desired end |
#missing? ⇒ Boolean
9 10 11 |
# File 'lib/acceptable_api/mapper.rb', line 9 def missing? false end |
#to?(desired) ⇒ Boolean
23 24 25 |
# File 'lib/acceptable_api/mapper.rb', line 23 def to? desired to == desired end |