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

#element_idString? Also known as: neo_id

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

Returns:

  • (String, nil)

    the neo4j id of the node if persisted or nil



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

def element_id
  _persisted_obj&.element_id
end

#hashObject



32
33
34
# File 'lib/active_graph/shared/identity.rb', line 32

def hash
  id.hash
end

#idObject



23
24
25
26
27
28
29
30
# File 'lib/active_graph/shared/identity.rb', line 23

def id
  if self.class.id_property_name
    send(self.class.id_property_name)
  else
    # Relationship
    neo_id
  end
end

#to_keyObject

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



12
13
14
# File 'lib/active_graph/shared/identity.rb', line 12

def to_key
  _persisted_obj ? [id] : nil
end