Sha256: b0f226b3fa90c57271dd55c3c54ea91c95f38e766ecd74ef4c649c9a3d503e4a

Contents?: true

Size: 557 Bytes

Versions: 8

Compression:

Stored size: 557 Bytes

Contents

module Toy
  module Equality
    extend ActiveSupport::Concern

    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
    alias :== :eql?

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

    def hash
      id.hash
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
toystore-0.13.0 lib/toy/equality.rb
toystore-0.12.0 lib/toy/equality.rb
toystore-0.11.0 lib/toy/equality.rb
toystore-0.10.4 lib/toy/equality.rb
toystore-0.10.3 lib/toy/equality.rb
toystore-0.10.2 lib/toy/equality.rb
toystore-0.10.1 lib/toy/equality.rb
toystore-0.10.0 lib/toy/equality.rb