Module: Neo4j::ActiveRel::Persistence::ClassMethods

Defined in:
lib/neo4j/active_rel/persistence.rb

Instance Method Summary collapse

Instance Method Details

#create(*args) ⇒ Object

Creates a new relationship between objects

Parameters:

  • props (Hash)

    the properties the new relationship should have



70
71
72
# File 'lib/neo4j/active_rel/persistence.rb', line 70

def create(*args)
  new(*args).tap(&:save)
end

#create!(*args) ⇒ Object

Same as #create, but raises an error if there is a problem during save.



75
76
77
# File 'lib/neo4j/active_rel/persistence.rb', line 75

def create!(*args)
  new(*args).tap(&:save!)
end

#create_methodObject



79
80
81
# File 'lib/neo4j/active_rel/persistence.rb', line 79

def create_method
  creates_unique? ? :create_unique : :create
end

#load_entity(id) ⇒ Object



83
84
85
# File 'lib/neo4j/active_rel/persistence.rb', line 83

def load_entity(id)
  query_as(id).pluck(:r).first
end

#query_as(neo_id, var = :r) ⇒ Object



87
88
89
# File 'lib/neo4j/active_rel/persistence.rb', line 87

def query_as(neo_id, var = :r)
  Neo4j::ActiveBase.new_query.match("()-[#{var}]->()").where(var => {neo_id: neo_id})
end