Module: Equatable::Methods

Defined in:
lib/equatable.rb

Overview

The equality methods

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Boolean

Compare two objects for equality based on their value and being a subclass of the given class.

Parameters:

  • other (Object)

    the other object in comparison

Returns:

  • (Boolean)


146
147
148
# File 'lib/equatable.rb', line 146

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

#eql?(other) ⇒ Boolean

Compare two objects for equality based on their value and being an instance of the given class.

Parameters:

  • other (Object)

    the other object in comparison

Returns:

  • (Boolean)


133
134
135
# File 'lib/equatable.rb', line 133

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