Class: MiniApi::DefaultResponder
- Inherits:
-
Object
- Object
- MiniApi::DefaultResponder
- Defined in:
- lib/mini_api/default_responder.rb
Instance Method Summary collapse
-
#initialize(controller, resource, options = {}) ⇒ DefaultResponder
constructor
A new instance of DefaultResponder.
- #respond ⇒ Object
Constructor Details
#initialize(controller, resource, options = {}) ⇒ DefaultResponder
Returns a new instance of DefaultResponder.
7 8 9 10 11 |
# File 'lib/mini_api/default_responder.rb', line 7 def initialize(controller, resource, = {}) @controller = controller @resource = resource = end |
Instance Method Details
#respond ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mini_api/default_responder.rb', line 13 def respond success = [:success] != false data = transform_keys body = if success { data: data } else { errors: data } end @controller.render( json: { success: success, message: [:message] || nil, **body }, status: [:status] || :ok ) end |