Sha256: 05af2381632ec53389f3028b77f83273455e4eac55474144ec07190a437e0087

Contents?: true

Size: 567 Bytes

Versions: 8

Compression:

Stored size: 567 Bytes

Contents

module Neo4j::Shared
  module Identity
    def ==(other)
      other.class == self.class && other.id == id
    end
    alias_method :eql?, :==

    # Returns an Enumerable of all (primary) key attributes
    # or nil if model.persisted? is false
    def to_key
      persisted? ? [id] : nil
    end

    # @return [Integer, nil] the neo4j id of the node if persisted or nil
    def neo_id
      _persisted_obj ? _persisted_obj.neo_id : nil
    end

    def id
      id = neo_id
      id.is_a?(Integer) ? id : nil
    end

    def hash
      id.hash
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
neo4j-5.0.0.rc.3 lib/neo4j/shared/identity.rb
neo4j-5.0.0.rc.2 lib/neo4j/shared/identity.rb
neo4j-5.0.0.rc.1 lib/neo4j/shared/identity.rb
neo4j-4.1.5 lib/neo4j/shared/identity.rb
neo4j-4.1.4 lib/neo4j/shared/identity.rb
neo4j-4.1.3 lib/neo4j/shared/identity.rb
neo4j-4.1.2 lib/neo4j/shared/identity.rb
neo4j-4.1.1 lib/neo4j/shared/identity.rb