class Datacaster::AndWithErrorAggregationNode

Public Class Methods

new(left, right) click to toggle source
# File lib/datacaster/and_with_error_aggregation_node.rb, line 3
def initialize(left, right)
  @left = left
  @right = right
end

Public Instance Methods

call(object) click to toggle source

Works like AndNode, but doesn't stop at first error — in order to aggregate all Failures Makes sense only for Hash Schemas

Calls superclass method
# File lib/datacaster/and_with_error_aggregation_node.rb, line 10
def call(object)
  object = super(object)

  left_result = @left.(object)

  if left_result.valid?
    @right.(left_result)
  else
    right_result = @right.(object)
    if right_result.valid?
      left_result
    else
      Datacaster.ErrorResult(self.class.merge_errors(left_result.errors, right_result.errors))
    end
  end
end
inspect() click to toggle source
# File lib/datacaster/and_with_error_aggregation_node.rb, line 27
def inspect
  "#<Datacaster::AndWithErrorAggregationNode L: #{@left.inspect} R: #{@right.inspect}>"
end