Class: OpenapiContracts::Validators::Base

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/openapi_contracts/validators/base.rb

Instance Method Summary collapse

Methods included from Helper

#http_status_desc

Constructor Details

#initialize(stack, env) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
# File 'lib/openapi_contracts/validators/base.rb', line 8

def initialize(stack, env)
  @stack = stack # next matcher
  @env = env
  @errors = []
end

Instance Method Details

#call(errors = []) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/openapi_contracts/validators/base.rb', line 14

def call(errors = [])
  validate
  errors.push(*@errors)
  # Do not call the next matcher when there is errors on a final matcher
  return errors if @errors.any? && final?

  @stack.call(errors)
end