class Hashema::Array::Comparison

Private Instance Methods

element_mismatches() click to toggle source
# File lib/hashema/schema.rb, line 62
def element_mismatches
  actual.each_with_index.flat_map do |element, i|
    element_comparison = expected.compare(element)

    element_comparison.mismatches.map do |mismatch|
      Mismatch.at i, mismatch
    end
  end
end
find_mismatches() click to toggle source
# File lib/hashema/schema.rb, line 53
def find_mismatches
  type_mismatches || element_mismatches
end
type_mismatches() click to toggle source
# File lib/hashema/schema.rb, line 57
def type_mismatches
  expectation = "be an Array, but got #{actual.class}"
  actual.is_a?(::Array) ? nil : [Mismatch.new(actual, ::Array, [], expectation)]
end