Class: AcceptableApi::Mapper
- Inherits:
-
Object
- Object
- AcceptableApi::Mapper
- Defined in:
- lib/acceptable_api.rb
Class Attribute Summary collapse
-
.mappers ⇒ Object
Returns the value of attribute mappers.
Class Method Summary collapse
Instance Method Summary collapse
- #execute(resource, request) ⇒ Object
- #headers ⇒ Object
-
#initialize(klass, mime_type, &map_block) ⇒ Mapper
constructor
A new instance of Mapper.
- #status ⇒ Object
Constructor Details
#initialize(klass, mime_type, &map_block) ⇒ Mapper
Returns a new instance of Mapper.
61 62 63 64 65 |
# File 'lib/acceptable_api.rb', line 61 def initialize klass, mime_type, &map_block self.klass = klass self.mime_type = mime_type self.map_block = map_block end |
Class Attribute Details
.mappers ⇒ Object
Returns the value of attribute mappers.
86 87 88 |
# File 'lib/acceptable_api.rb', line 86 def mappers @mappers end |
Class Method Details
Instance Method Details
#execute(resource, request) ⇒ Object
67 68 69 70 |
# File 'lib/acceptable_api.rb', line 67 def execute resource, request body = map_block.call resource, request [ status, headers, body ] end |
#headers ⇒ Object
76 77 78 |
# File 'lib/acceptable_api.rb', line 76 def headers { 'Content-Type' => mime_type } end |
#status ⇒ Object
72 73 74 |
# File 'lib/acceptable_api.rb', line 72 def status 200 end |