Module: ActiveGraph::Shared::Identity
- Included in:
- Node, Relationship
- Defined in:
- lib/active_graph/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?
4 5 6 |
# File 'lib/active_graph/shared/identity.rb', line 4 def ==(other) other.class == self.class && other.id == id end |
#hash ⇒ Object
29 30 31 |
# File 'lib/active_graph/shared/identity.rb', line 29 def hash id.hash end |
#id ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/active_graph/shared/identity.rb', line 20 def id if self.class.id_property_name send(self.class.id_property_name) else # Relationship neo_id end end |
#neo_id ⇒ Integer?
Returns the neo4j id of the node if persisted or nil.
16 17 18 |
# File 'lib/active_graph/shared/identity.rb', line 16 def neo_id _persisted_obj ? _persisted_obj.id : nil end |
#to_key ⇒ Object
Returns an Enumerable of all (primary) key attributes or nil if model.persisted? is false
11 12 13 |
# File 'lib/active_graph/shared/identity.rb', line 11 def to_key _persisted_obj ? [id] : nil end |