Class: Vanguard::Evaluator
- Inherits:
-
Object
- Object
- Vanguard::Evaluator
- Includes:
- AbstractType, Adamantium::Flat
- Defined in:
- lib/vanguard/evaluator.rb
Overview
Abstract base class for rule evaluators
Direct Known Subclasses
Rule::Guard::Evaluator, Rule::Nullary::Attribute::Evaluator, Rule::Nullary::Confirmation::Evaluator
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
private
Return validated resource.
-
#rule ⇒ Rule
readonly
private
Return rule.
Instance Method Summary collapse
-
#initialize(rule, resource) ⇒ undefined
constructor
private
Initialize object.
-
#value ⇒ Object
private
Return value to be validated.
-
#violation ⇒ Violation
private
Return violation.
-
#violations ⇒ Enumerable<Violation>
private
Return violations.
Constructor Details
#initialize(rule, resource) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize object
31 32 33 |
# File 'lib/vanguard/evaluator.rb', line 31 def initialize(rule, resource) @rule, @resource = rule, resource end |
Instance Attribute Details
#resource ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return validated resource
12 13 14 |
# File 'lib/vanguard/evaluator.rb', line 12 def resource @resource end |
#rule ⇒ Rule (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return rule
20 21 22 |
# File 'lib/vanguard/evaluator.rb', line 20 def rule @rule end |
Instance Method Details
#value ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return value to be validated
41 42 43 |
# File 'lib/vanguard/evaluator.rb', line 41 def value resource.public_send(rule.attribute_name) end |
#violation ⇒ Violation
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return violation
52 53 54 |
# File 'lib/vanguard/evaluator.rb', line 52 def violation Violation.new(rule, resource) end |
#violations ⇒ Enumerable<Violation>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return violations
63 64 65 66 67 68 69 |
# File 'lib/vanguard/evaluator.rb', line 63 def violations unless valid? [violation] else [] end end |