Module: Toy::Equality

Extended by:
ActiveSupport::Concern
Included in:
Object
Defined in:
lib/toy/equality.rb

Instance Method Summary collapse

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:



5
6
7
8
9
10
11
# File 'lib/toy/equality.rb', line 5

def eql?(other)
  return true if self.class.eql?(other.class) && id == other.id
  return true if other.respond_to?(:target) &&
                 self.class.eql?(other.target.class) &&
                 id == other.target.id
  false
end

#equal?(other) ⇒ Boolean

Returns:



14
15
16
17
18
19
# File 'lib/toy/equality.rb', line 14

def equal?(other)
  if other.respond_to?(:proxy_respond_to?) && other.respond_to?(:target)
    other = other.target
  end
  super other
end

#hashObject



21
22
23
# File 'lib/toy/equality.rb', line 21

def hash
  id.hash
end