Sha256: 44086df3a352b249ed750a3235beb5857df4606b880ab348288266c8535c5a91

Contents?: true

Size: 646 Bytes

Versions: 8

Compression:

Stored size: 646 Bytes

Contents

module Foobara
  class DetachedEntity
    module Concerns
      module Equality
        include Concern

        def dup
          # TODO: Maybe raise instead?
          self
        end

        def ==(other)
          # Should both records be required to be persisted to be considered equal when having matching primary keys?
          # For now we will consider them equal but it could make sense to consider them not equal.
          equal?(other) || (self.class == other.class && primary_key && primary_key == other.primary_key)
        end

        def hash
          (primary_key || object_id).hash
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
foobara-0.0.38 projects/detached_entity/src/concerns/equality.rb
foobara-0.0.37 projects/detached_entity/src/concerns/equality.rb
foobara-0.0.36 projects/detached_entity/src/concerns/equality.rb
foobara-0.0.35 projects/detached_entity/src/concerns/equality.rb
foobara-0.0.34 projects/detached_entity/src/concerns/equality.rb
foobara-0.0.33 projects/detached_entity/src/concerns/equality.rb
foobara-0.0.32 projects/detached_entity/src/concerns/equality.rb
foobara-0.0.31 projects/detached_entity/src/concerns/equality.rb