Class: Lite::Validation::Validator::Node::Implementation::Scoping::Evaluator
- Inherits:
-
Object
- Object
- Lite::Validation::Validator::Node::Implementation::Scoping::Evaluator
- Defined in:
- lib/lite/validation/validator/node/implementation/scoping/evaluator.rb
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#validator ⇒ Object
readonly
Returns the value of attribute validator.
Class Method Summary collapse
Instance Method Summary collapse
- #and(path, &block) ⇒ Object
- #call(&block) ⇒ Object
-
#initialize(validator, paths) ⇒ Evaluator
constructor
A new instance of Evaluator.
Constructor Details
#initialize(validator, paths) ⇒ Evaluator
Returns a new instance of Evaluator.
18 19 20 21 |
# File 'lib/lite/validation/validator/node/implementation/scoping/evaluator.rb', line 18 def initialize(validator, paths) @validator = validator @paths = paths end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
30 31 32 |
# File 'lib/lite/validation/validator/node/implementation/scoping/evaluator.rb', line 30 def paths @paths end |
#validator ⇒ Object (readonly)
Returns the value of attribute validator.
30 31 32 |
# File 'lib/lite/validation/validator/node/implementation/scoping/evaluator.rb', line 30 def validator @validator end |
Class Method Details
.instance(validator, path) ⇒ Object
12 13 14 |
# File 'lib/lite/validation/validator/node/implementation/scoping/evaluator.rb', line 12 def self.instance(validator, path) new(validator, [path].freeze) end |
Instance Method Details
#and(path, &block) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/lite/validation/validator/node/implementation/scoping/evaluator.rb', line 23 def and(path, &block) compound = self.class.send(:new, validator, [*paths, path]) return compound if block.nil? compound.call(&block) end |
#call(&block) ⇒ Object
32 33 34 35 36 |
# File 'lib/lite/validation/validator/node/implementation/scoping/evaluator.rb', line 32 def call(&block) return validator unless paths.all? { validator.result.success_at?(*_1) } Helpers::WithResult.with_result(validator, validator.send(:wrap, &block)) end |