Class: Praxis::RequestStages::ValidateParamsAndHeaders
- Inherits:
-
RequestStage
- Object
- Stage
- RequestStage
- Praxis::RequestStages::ValidateParamsAndHeaders
- Defined in:
- lib/praxis/request_stages/validate_params_and_headers.rb
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Attributes inherited from Stage
#after_callbacks, #before_callbacks, #context, #name, #stages
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(name, context, parent:) ⇒ ValidateParamsAndHeaders
constructor
A new instance of ValidateParamsAndHeaders.
- #path ⇒ Object
Methods inherited from RequestStage
#action, #controller, #execute_controller_callbacks, #execute_with_around, #request, #run, #setup!, #validation_handler
Methods inherited from Stage
#after, #application, #before, #callback_args, #execute_callbacks, #run, #setup!, #setup_deferred_callbacks!
Constructor Details
#initialize(name, context, parent:) ⇒ ValidateParamsAndHeaders
Returns a new instance of ValidateParamsAndHeaders.
8 9 10 11 |
# File 'lib/praxis/request_stages/validate_params_and_headers.rb', line 8 def initialize(name, context, parent:) super @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/praxis/request_stages/validate_params_and_headers.rb', line 6 def parent @parent end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/praxis/request_stages/validate_params_and_headers.rb', line 17 def execute begin request.load_headers(CONTEXT_FOR[:headers]) rescue StandardError => e = 'Error loading headers.' return validation_handler.handle!( exception: e, summary: , request: request, stage: name ) end begin request.load_params(CONTEXT_FOR[:params]) rescue Attributor::AttributorException => e = 'Error loading params.' return validation_handler.handle!( exception: e, summary: , request: request, stage: name ) end errors = request.validate_headers(CONTEXT_FOR[:headers]) errors += request.validate_params(CONTEXT_FOR[:params]) return unless errors.any? = 'Error validating request data.' validation_handler.handle!( summary: , errors: errors, request: request, stage: name ) end |
#path ⇒ Object
13 14 15 |
# File 'lib/praxis/request_stages/validate_params_and_headers.rb', line 13 def path @path ||= (@parent.path + [name]) end |