Class: EasyJSONMatcher::ValidationStep
- Inherits:
-
Object
- Object
- EasyJSONMatcher::ValidationStep
- Defined in:
- lib/easy_json_matcher/validation_step.rb
Instance Attribute Summary collapse
-
#next_step ⇒ Object
readonly
Returns the value of attribute next_step.
-
#verifier ⇒ Object
readonly
Returns the value of attribute verifier.
Instance Method Summary collapse
- #>>(step) ⇒ Object
- #call(value:) ⇒ Object
- #concat(chain) ⇒ Object
-
#initialize(verify_with:) ⇒ ValidationStep
constructor
A new instance of ValidationStep.
- #is_tail? ⇒ Boolean
Constructor Details
#initialize(verify_with:) ⇒ ValidationStep
Returns a new instance of ValidationStep.
11 12 13 |
# File 'lib/easy_json_matcher/validation_step.rb', line 11 def initialize(verify_with:) @verifier = verify_with end |
Instance Attribute Details
#next_step ⇒ Object (readonly)
Returns the value of attribute next_step.
9 10 11 |
# File 'lib/easy_json_matcher/validation_step.rb', line 9 def next_step @next_step end |
#verifier ⇒ Object (readonly)
Returns the value of attribute verifier.
9 10 11 |
# File 'lib/easy_json_matcher/validation_step.rb', line 9 def verifier @verifier end |
Instance Method Details
#>>(step) ⇒ Object
24 25 26 |
# File 'lib/easy_json_matcher/validation_step.rb', line 24 def >>(step) @next_step = step end |
#call(value:) ⇒ Object
15 16 17 18 19 20 21 22 |
# 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) ⇒ Object
28 29 30 |
# File 'lib/easy_json_matcher/validation_step.rb', line 28 def concat(chain) is_tail? ? self.>>(chain) : next_step.concat(chain) end |
#is_tail? ⇒ Boolean
32 33 34 |
# File 'lib/easy_json_matcher/validation_step.rb', line 32 def is_tail? next_step.nil? end |