Module: Neo4j::ActiveRel::Persistence
Defined Under Namespace
Modules: ClassMethods
Classes: ModelClassInvalidError, QueryFactory, RelCreateFailedError, RelInvalidError
Instance Method Summary
collapse
class_methods
#apply_default_values, #cache_key, #create_or_update, #destroy, #destroyed?, #exist?, #freeze, #frozen?, #increment, #increment!, #new_record?, #persisted?, #props, #props_for_create, #props_for_persistence, #props_for_update, #reload, #reload_from_database, #touch, #update, #update!, #update_attribute, #update_attribute!, #update_model
Instance Method Details
#concurrent_increment!(attribute, by = 1) ⇒ Object
Increments concurrently a numeric attribute by a centain amount
42
43
44
45
|
# File 'lib/neo4j/active_rel/persistence.rb', line 42
def concurrent_increment!(attribute, by = 1)
query_rel = Neo4j::Session.query.match('()-[n]-()').where(n: {neo_id: neo_id})
increment_by_query! query_rel, attribute, by
end
|
#create_method ⇒ Object
76
77
78
|
# File 'lib/neo4j/active_rel/persistence.rb', line 76
def create_method
self.class.create_method
end
|
#create_model ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/neo4j/active_rel/persistence.rb', line 47
def create_model
validate_node_classes!
rel = _create_rel
return self unless rel.respond_to?(:props)
init_on_load(rel, from_node, to_node, @rel_type)
true
end
|
#cypher_identifier ⇒ Object
27
28
29
|
# File 'lib/neo4j/active_rel/persistence.rb', line 27
def cypher_identifier
@cypher_identifier || :rel
end
|
#from_node_identifier ⇒ Object
11
12
13
|
# File 'lib/neo4j/active_rel/persistence.rb', line 11
def from_node_identifier
@from_node_identifier || :from_node
end
|
#from_node_identifier=(id) ⇒ Object
19
20
21
|
# File 'lib/neo4j/active_rel/persistence.rb', line 19
def from_node_identifier=(id)
@from_node_identifier = id.to_sym
end
|
#save ⇒ Object
31
32
33
|
# File 'lib/neo4j/active_rel/persistence.rb', line 31
def save(*)
create_or_update
end
|
#save!(*args) ⇒ Object
35
36
37
|
# File 'lib/neo4j/active_rel/persistence.rb', line 35
def save!(*args)
save(*args) or fail(RelInvalidError, inspect)
end
|
#to_node_identifier ⇒ Object
15
16
17
|
# File 'lib/neo4j/active_rel/persistence.rb', line 15
def to_node_identifier
@to_node_identifier || :to_node
end
|
#to_node_identifier=(id) ⇒ Object
23
24
25
|
# File 'lib/neo4j/active_rel/persistence.rb', line 23
def to_node_identifier=(id)
@to_node_identifier = id.to_sym
end
|