module DeepClassCompare::ContainerComparable

Private Instance Methods

compare_chain(value, chain) click to toggle source
# File lib/deep_class_compare/container_comparable.rb, line 4
def compare_chain(value, chain)
  case chain
  when Matcher then chain.match?(value)
  when Array then chain.any? { |matcher| matcher.match?(value) }
  else true
  end
end
parse_array_to_chain(array) click to toggle source
# File lib/deep_class_compare/container_comparable.rb, line 21
def parse_array_to_chain(array)
  case array.count
  when 0 then raise_pattern_error!
  when 1 then parse_comparable_to_chain(array.first)
  else
    array.map do |sub_comparable|
      parse_comparable_to_chain(sub_comparable)
    end
  end
end
parse_comparable_to_chain(comparable) click to toggle source
# File lib/deep_class_compare/container_comparable.rb, line 12
def parse_comparable_to_chain(comparable)
  case comparable
  when Matcher then comparable
  when Array then parse_array_to_chain(comparable)
  when Class then Matcher.build(comparable)
  else raise_pattern_error!
  end        
end