Module: Dry::Equalizer::Methods

Defined in:
lib/dry/equalizer.rb

Overview

The comparison methods

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Boolean

Compare the object with other object for equivalency

Examples:

object == other  # => true or false

Parameters:

  • other (Object)

    the other object to compare with

Returns:

  • (Boolean)


138
139
140
# File 'lib/dry/equalizer.rb', line 138

def ==(other)
  other.is_a?(self.class) && cmp?(__method__, other)
end

#eql?(other) ⇒ Boolean

Compare the object with other object for equality

Examples:

object.eql?(other)  # => true or false

Parameters:

  • other (Object)

    the other object to compare with

Returns:

  • (Boolean)


123
124
125
# File 'lib/dry/equalizer.rb', line 123

def eql?(other)
  instance_of?(other.class) && cmp?(__method__, other)
end