Class: MiniApi::Responder
- Inherits:
-
Object
- Object
- MiniApi::Responder
- Defined in:
- lib/mini_api/responder.rb
Instance Method Summary collapse
- #default_responder ⇒ Object
-
#initialize(controller, resource, options = {}) ⇒ Responder
constructor
A new instance of Responder.
- #model_responder ⇒ Object
- #relation_responder ⇒ Object
- #respond ⇒ Object
Constructor Details
#initialize(controller, resource, options = {}) ⇒ Responder
Returns a new instance of Responder.
9 10 11 12 13 |
# File 'lib/mini_api/responder.rb', line 9 def initialize(controller, resource, = {}) @controller = controller @resource = resource @options = end |
Instance Method Details
#default_responder ⇒ Object
34 35 36 |
# File 'lib/mini_api/responder.rb', line 34 def default_responder DefaultResponder.new(@controller, @resource, @options) end |
#model_responder ⇒ Object
30 31 32 |
# File 'lib/mini_api/responder.rb', line 30 def model_responder ModelResponder.new(@controller, @resource, @options) end |
#relation_responder ⇒ Object
26 27 28 |
# File 'lib/mini_api/responder.rb', line 26 def relation_responder RelationResponder.new(@controller, @resource, @options) end |
#respond ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mini_api/responder.rb', line 15 def respond case @resource when ActiveRecord::Relation relation_responder.respond when ActiveRecord::Base, ActiveModel::Model model_responder.respond else default_responder.respond end end |