Class: Praxis::RequestStages::Action
- Inherits:
-
RequestStage
- Object
- Stage
- RequestStage
- Praxis::RequestStages::Action
- Defined in:
- lib/praxis/request_stages/action.rb
Instance Attribute Summary
Attributes inherited from Stage
#after_callbacks, #before_callbacks, #context, #name, #stages
Instance Method Summary collapse
Methods inherited from RequestStage
#action, #controller, #execute_controller_callbacks, #execute_with_around, #path, #request, #run, #setup!, #validation_handler
Methods inherited from Stage
#after, #application, #before, #callback_args, #execute_callbacks, #initialize, #run, #setup!, #setup_deferred_callbacks!
Constructor Details
This class inherits a constructor from Praxis::Stage
Instance Method Details
#execute ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/praxis/request_stages/action.rb', line 6 def execute response = Notifications.instrument 'praxis.request_stage.execute', controller: controller do if controller.method(action.name).arity.zero? controller.__send__(action.name) else controller.__send__(action.name, **request.params_hash) end end case response when String controller.response.body = response when Praxis::Response controller.response = response else raise "Action #{action.name} in #{controller.class} returned #{response.inspect}. Only Response objects or Strings allowed." end controller.response.request = request nil # Action cannot return its OK request, as it would indicate the end of the stage chain end |