Class: Suture::Comparator

Inherits:
Object
  • Object
show all
Defined in:
lib/suture/comparator.rb

Constant Summary collapse

DEFAULT_ACTIVE_RECORD_EXCLUDED_ATTRIBUTES =
[:updated_at, :created_at]

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Comparator

Returns a new instance of Comparator.



5
6
7
8
9
10
11
12
# File 'lib/suture/comparator.rb', line 5

def initialize(options = {})
  @options = {
    :active_record_excluded_attributes => (
      options[:active_record_excluded_attributes] ||
        DEFAULT_ACTIVE_RECORD_EXCLUDED_ATTRIBUTES
    ).map(&:to_s)
  }
end

Instance Method Details

#call(recorded, actual) ⇒ Object



14
15
16
17
# File 'lib/suture/comparator.rb', line 14

def call(recorded, actual)
  is_equalivalent?(recorded, actual) ||
    Marshal.dump(recorded) == Marshal.dump(actual)
end

#inspectObject



19
20
21
# File 'lib/suture/comparator.rb', line 19

def inspect
  "#{self.class}.new(#{@options.inspect})"
end