Module: ActiveGraph::Shared::Identity

Included in:
Node, Relationship
Defined in:
lib/active_graph/shared/identity.rb

Instance Method Summary collapse

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

#hashObject



29
30
31
# File 'lib/active_graph/shared/identity.rb', line 29

def hash
  id.hash
end

#idObject



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_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



16
17
18
# File 'lib/active_graph/shared/identity.rb', line 16

def neo_id
  _persisted_obj ? _persisted_obj.id : nil
end

#to_keyObject

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