Class: Ippon::Validate::Merge

Inherits:
Schema
  • Object
show all
Defined in:
lib/ippon/validate.rb

Overview

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Schema

#&, #unhalt, #validate, #validate!, #|

Constructor Details

#initialize(left, right) ⇒ Merge

Returns a new instance of Merge.


774
775
776
777
# File 'lib/ippon/validate.rb', line 774

def initialize(left, right)
  @left = left
  @right = right
end

Instance Attribute Details

#leftSchema (readonly)

Returns:


770
771
772
# File 'lib/ippon/validate.rb', line 770

def left
  @left
end

#rightSchema (readonly)

Returns:


772
773
774
# File 'lib/ippon/validate.rb', line 772

def right
  @right
end

Instance Method Details

#process(result) ⇒ Object

Implements the Schema#process interface.


780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# File 'lib/ippon/validate.rb', line 780

def process(result)
  left_result = result.dup
  right_result = result.dup

  @left.process(left_result)
  @right.process(right_result)

  result.add_errors_from(left_result)
  result.add_errors_from(right_result)

  result.value = {}
  result.value.update(left_result.value) if !left_result.halted?
  result.value.update(right_result.value) if !right_result.halted?
  result
end