Class: Lite::Validation::Validator::Result::Disputed::Navigable
- Inherits:
-
Abstract::Hash
- Object
- Abstract::Hash
- Lite::Validation::Validator::Result::Disputed::Navigable
- Defined in:
- lib/lite/validation/validator/result/disputed/navigable.rb
Class Method Summary collapse
Instance Method Summary collapse
- #auto_commit(as:) ⇒ Object
- #commit(_value) ⇒ Object
- #dispute(error) ⇒ Object
-
#initialize(errors, children, *args) ⇒ Navigable
constructor
A new instance of Navigable.
- #inspect ⇒ Object
- #iterable(commit:) ⇒ Object
- #merge(result, key) ⇒ Object
Methods included from Lite::Validation::Validator::Result::Disputable::Navigable
Methods included from Lite::Validation::Validator::Result::Disputable::Hash
Constructor Details
#initialize(errors, children, *args) ⇒ Navigable
Returns a new instance of Navigable.
19 20 21 |
# File 'lib/lite/validation/validator/result/disputed/navigable.rb', line 19 def initialize(errors, children, *args) super(errors.freeze, children.freeze, *args) end |
Class Method Details
.instance(*args, error: nil) ⇒ Object
14 15 16 17 |
# File 'lib/lite/validation/validator/result/disputed/navigable.rb', line 14 def self.instance(*args, error: nil) instance = new([], EMPTY, *args) error ? instance.dispute(error) : instance end |
Instance Method Details
#auto_commit(as:) ⇒ Object
27 28 29 |
# File 'lib/lite/validation/validator/result/disputed/navigable.rb', line 27 def auto_commit(as:) self end |
#commit(_value) ⇒ Object
23 24 25 |
# File 'lib/lite/validation/validator/result/disputed/navigable.rb', line 23 def commit(_value) self end |
#dispute(error) ⇒ Object
31 32 33 34 35 |
# File 'lib/lite/validation/validator/result/disputed/navigable.rb', line 31 def dispute(error) raise Error::Fatal, "Structured error expected, got: #{error.inspect}" unless error.is_a?(StructuredError) self.class.send :new, [*errors_root, error], children end |
#inspect ⇒ Object
37 38 39 |
# File 'lib/lite/validation/validator/result/disputed/navigable.rb', line 37 def inspect signature('Disputed::Navigable') end |
#iterable(commit:) ⇒ Object
41 42 43 |
# File 'lib/lite/validation/validator/result/disputed/navigable.rb', line 41 def iterable(commit:) Iterable::Hash.instance(errors_root, children) end |
#merge(result, key) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/lite/validation/validator/result/disputed/navigable.rb', line 45 def merge(result, key) return self if result.success? self.class.send( :new, errors_root, children.merge(key => result) ) end |