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
#execute_controller_callbacks, #execute_with_around, #run
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.
7 8 9 10 |
# File 'lib/praxis/request_stages/validate_params_and_headers.rb', line 7 def initialize(name, context, parent:) super @parent = parent end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
5 6 7 |
# File 'lib/praxis/request_stages/validate_params_and_headers.rb', line 5 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 |
# File 'lib/praxis/request_stages/validate_params_and_headers.rb', line 17 def execute request.load_headers(CONTEXT_FOR[:headers]) request.load_params(CONTEXT_FOR[:params]) attribute_resolver = Attributor::AttributeResolver.new Attributor::AttributeResolver.current = attribute_resolver attribute_resolver.register("headers",request.headers) attribute_resolver.register("params",request.params) errors = request.validate_headers(CONTEXT_FOR[:headers]) errors += request.validate_params(CONTEXT_FOR[:params]) if errors.any? return Responses::ValidationError.new(errors: errors) end end |
#path ⇒ Object
13 14 15 |
# File 'lib/praxis/request_stages/validate_params_and_headers.rb', line 13 def path @parent.path + [name] end |