Module: Schema::Assertions

Defined in:
lib/schema/schema/assertions.rb

Instance Method Summary collapse

Instance Method Details

#attributes_equal?(other, attributes = nil, print: nil) ⇒ Boolean

Returns:



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/schema/schema/assertions.rb', line 3

def attributes_equal?(other, attributes=nil, print: nil)
  attributes ||= self.class.attribute_names

  print = true if print.nil?
  print ||= false

  equal = self.eql?(other, attributes, ignore_class: true)

  if !equal && print
    attributes = Array(attributes)

    require 'pp'
    puts "self: #{self.class.name}"
    pp self.attributes.select { |k, v| attributes.include? k }
    puts "other #{other.class.name}:"
    pp other.attributes.select { |k, v| attributes.include? k }
    puts "attributes:"
    attributes.each { |a| puts a.inspect}
  end

  equal
end