Class: Ippon::Validate::Merge
Overview
Instance Attribute Summary collapse
- #left ⇒ Schema readonly
- #right ⇒ Schema readonly
Instance Method Summary collapse
-
#initialize(left, right) ⇒ Merge
constructor
A new instance of Merge.
-
#process(result) ⇒ Object
Implements the Schema#process interface.
Methods inherited from Schema
#&, #unhalt, #validate, #validate!, #|
Constructor Details
#initialize(left, right) ⇒ Merge
Returns a new instance of Merge.
876 877 878 879 |
# File 'lib/ippon/validate.rb', line 876 def initialize(left, right) @left = left @right = right end |
Instance Attribute Details
#right ⇒ Schema (readonly)
874 875 876 |
# File 'lib/ippon/validate.rb', line 874 def right @right end |
Instance Method Details
#process(result) ⇒ Object
Implements the Schema#process interface.
882 883 884 885 886 887 888 889 890 891 892 893 |
# File 'lib/ippon/validate.rb', line 882 def process(result) left_result = @left.validate(result.value) right_result = @right.validate(result.value) result.mutable_errors.merge!(left_result.errors) if left_result.error? result.mutable_errors.merge!(right_result.errors) if right_result.error? result.value = {} result.value.update(left_result.value) if !left_result.halted? result.value.update(right_result.value) if !right_result.halted? result end |