Module: Equalizer::Methods

Defined in:
lib/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


114
115
116
117
# File 'lib/equalizer.rb', line 114

def ==(other)
  other = coerce(other).first if respond_to?(:coerce, true)
  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


99
100
101
# File 'lib/equalizer.rb', line 99

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