Class: Praxis::RequestStages::Response
- Inherits:
-
RequestStage
- Object
- Stage
- RequestStage
- Praxis::RequestStages::Response
- Defined in:
- lib/praxis/request_stages/response.rb
Constant Summary collapse
- WHITELIST_RESPONSES =
[:validation_error]
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!
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
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/praxis/request_stages/response.rb', line 7 def execute response = controller.response unless action.responses.include?(response.response_name) || WHITELIST_RESPONSES.include?(response.response_name) raise Exceptions::InvalidResponse.new( "Response #{response.name.inspect} is not allowed for #{action.name.inspect}" ) end response.handle if Application.instance.config.praxis.validate_responses == true response.validate(action) end rescue Exceptions::Validation => e controller.response = Responses::ValidationError.new(exception: e) retry end |