Class: Interpol::RequestBodyValidator::Handler
- Inherits:
-
Object
- Object
- Interpol::RequestBodyValidator::Handler
- Defined in:
- lib/interpol/request_body_validator.rb
Overview
Handles request body validation for a single request.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
-
#initialize(env, config) ⇒ Handler
constructor
A new instance of Handler.
- #parse ⇒ Object
- #validate(&block) ⇒ Object
Constructor Details
#initialize(env, config) ⇒ Handler
Returns a new instance of Handler.
31 32 33 34 |
# File 'lib/interpol/request_body_validator.rb', line 31 def initialize(env, config) @env = env @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
29 30 31 |
# File 'lib/interpol/request_body_validator.rb', line 29 def config @config end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
29 30 31 |
# File 'lib/interpol/request_body_validator.rb', line 29 def env @env end |
Instance Method Details
#parse ⇒ Object
36 37 38 |
# File 'lib/interpol/request_body_validator.rb', line 36 def parse DynamicStruct.new(parsed_body) end |
#validate(&block) ⇒ Object
40 41 42 43 44 |
# File 'lib/interpol/request_body_validator.rb', line 40 def validate(&block) endpoint_definition(&block).validate_data!(parsed_body) rescue Interpol::ValidationError => e yield @config.request_body_invalid(env, e) end |