Module: Neo4j::Shared::Identity

Included in:
ActiveNode, ActiveRel
Defined in:
lib/neo4j/shared/identity.rb

Instance Method Summary collapse

Instance Method Details

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



3
4
5
# File 'lib/neo4j/shared/identity.rb', line 3

def ==(other)
  other.class == self.class && other.id == id
end

#hashObject



24
25
26
# File 'lib/neo4j/shared/identity.rb', line 24

def hash
  id.hash
end

#idObject



19
20
21
22
# File 'lib/neo4j/shared/identity.rb', line 19

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

#neo_idInteger?

Returns the neo4j id of the node if persisted or nil.

Returns:

  • (Integer, nil)

    the neo4j id of the node if persisted or nil



15
16
17
# File 'lib/neo4j/shared/identity.rb', line 15

def neo_id
  _persisted_obj ? _persisted_obj.neo_id : nil
end

#to_keyObject

Returns an Enumerable of all (primary) key attributes or nil if model.persisted? is false



10
11
12
# File 'lib/neo4j/shared/identity.rb', line 10

def to_key
  _persisted_obj ? [id] : nil
end