Class: Daredevil::Responder
- Inherits:
-
Object
- Object
- Daredevil::Responder
- Includes:
- Actions, Responses, Sanitizers
- Defined in:
- lib/daredevil/responder.rb,
lib/daredevil/responder/actions.rb,
lib/daredevil/responder/responses.rb,
lib/daredevil/responder/sanitizers.rb
Defined Under Namespace
Modules: Actions, Responses, Sanitizers
Constant Summary
Constants included from Actions
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(resource, options = {}) ⇒ Responder
constructor
A new instance of Responder.
- #render_response ⇒ Object
- #respond! ⇒ Object
Methods included from Sanitizers
Methods included from Responses
#not_found, #parameter_missing, #unauthorized
Methods included from Actions
#jbuilder_resource_render_options, #relation?, #render_resource, #resource_class, #resource_render_options, #respond_to_create_action, #respond_to_destroy_action, #respond_to_update_action, #responder_type, #serializer_class, #serializers_resource_render_options, #supported_responders
Constructor Details
#initialize(resource, options = {}) ⇒ Responder
Returns a new instance of Responder.
20 21 22 23 24 25 26 27 |
# File 'lib/daredevil/responder.rb', line 20 def initialize(resource, = {}) @resource = resource @options = self.status = @options[:status] @params = @options[:params] @controller = @options[:controller] @namespace = @options[:namespace] end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
17 18 19 |
# File 'lib/daredevil/responder.rb', line 17 def controller @controller end |
#errors ⇒ Object
Returns the value of attribute errors.
12 13 14 |
# File 'lib/daredevil/responder.rb', line 12 def errors @errors end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
18 19 20 |
# File 'lib/daredevil/responder.rb', line 18 def namespace @namespace end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/daredevil/responder.rb', line 15 def @options end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
16 17 18 |
# File 'lib/daredevil/responder.rb', line 16 def params @params end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
14 15 16 |
# File 'lib/daredevil/responder.rb', line 14 def resource @resource end |
#status ⇒ Object
Returns the value of attribute status.
13 14 15 |
# File 'lib/daredevil/responder.rb', line 13 def status @status end |
Instance Method Details
#render_response ⇒ Object
33 34 35 36 |
# File 'lib/daredevil/responder.rb', line 33 def render_response return send("respond_to_#{action}_action") if action.in?(ACTIONS) raise(Daredevil::Errors::UnknownAction, action) end |
#respond! ⇒ Object
29 30 31 |
# File 'lib/daredevil/responder.rb', line 29 def respond! render_response end |