class EasyJSONMatcher::ValidationStep

Attributes

next_step[R]
verifier[R]

Public Class Methods

new(verify_with:) click to toggle source
# File lib/easy_json_matcher/validation_step.rb, line 11
def initialize(verify_with:)
  @verifier = verify_with
end

Public Instance Methods

>>(step) click to toggle source
# File lib/easy_json_matcher/validation_step.rb, line 24
def >>(step)
  @next_step = step
end
call(value:) click to toggle source
# File lib/easy_json_matcher/validation_step.rb, line 15
def call(value:)
  errors = []
  if verifier.call(value, errors) == false || is_tail?
    errors
  else
    errors + next_step.call(value: value)
  end
end
concat(chain) click to toggle source
# File lib/easy_json_matcher/validation_step.rb, line 28
def concat(chain)
  is_tail? ? self.>>(chain) : next_step.concat(chain)
end
is_tail?() click to toggle source
# File lib/easy_json_matcher/validation_step.rb, line 32
def is_tail?
  next_step.nil?
end