Class: NxtSchema::Validator::ValidateWithProxy
- Inherits:
-
Object
- Object
- NxtSchema::Validator::ValidateWithProxy
- Defined in:
- lib/nxt_schema/validators/validate_with_proxy.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #add_error(error) ⇒ Object
- #copy_aggregated_errors_to_node ⇒ Object
-
#initialize(node) ⇒ ValidateWithProxy
constructor
A new instance of ValidateWithProxy.
- #validate(&block) ⇒ Object
Constructor Details
#initialize(node) ⇒ ValidateWithProxy
Returns a new instance of ValidateWithProxy.
4 5 6 7 |
# File 'lib/nxt_schema/validators/validate_with_proxy.rb', line 4 def initialize(node) @node = node @aggregated_errors = [] end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
9 10 11 |
# File 'lib/nxt_schema/validators/validate_with_proxy.rb', line 9 def node @node end |
Instance Method Details
#add_error(error) ⇒ Object
20 21 22 23 |
# File 'lib/nxt_schema/validators/validate_with_proxy.rb', line 20 def add_error(error) aggregated_errors << error false end |
#copy_aggregated_errors_to_node ⇒ Object
25 26 27 28 29 |
# File 'lib/nxt_schema/validators/validate_with_proxy.rb', line 25 def copy_aggregated_errors_to_node aggregated_errors.each do |error| node.add_error(error) end end |
#validate(&block) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/nxt_schema/validators/validate_with_proxy.rb', line 13 def validate(&block) result = instance_exec(&block) return if result copy_aggregated_errors_to_node end |