Module: Neo4j::Shared::Identity
- Included in:
- ActiveNode, ActiveRel
- Defined in:
- lib/neo4j/shared/identity.rb
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
- #id ⇒ Object
-
#neo_id ⇒ Integer?
The neo4j id of the node if persisted or nil.
-
#to_key ⇒ Object
Returns an Enumerable of all (primary) key attributes or nil if model.persisted? is false.
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 |
#hash ⇒ Object
24 25 26 |
# File 'lib/neo4j/shared/identity.rb', line 24 def hash id.hash end |
#id ⇒ Object
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_id ⇒ Integer?
Returns 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_key ⇒ Object
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 |