Module: ActiveGraph::Relationship::Persistence
Defined Under Namespace
Modules: ClassMethods
Classes: ModelClassInvalidError, QueryFactory, RelCreateFailedError, RelInvalidError
Instance Method Summary
collapse
#apply_default_values, #cache_key, #create_or_update, #destroy, #destroyed?, #exist?, #freeze, #frozen?, #increment, #increment!, #inject_primary_key!, #new_record?, #persisted?, #props, #props_for_create, #props_for_persistence, #props_for_update, #reload, #reload_from_database, #skip_update?, #touch, #update, #update!, #update_attribute, #update_attribute!, #update_db_properties, #update_db_property, #update_model
Instance Method Details
#concurrent_increment!(attribute, by = 1) ⇒ Object
Increments concurrently a numeric attribute by a centain amount
44
45
46
|
# File 'lib/active_graph/relationship/persistence.rb', line 44
def concurrent_increment!(attribute, by = 1)
increment_by_query! query_as(:r), attribute, by, :r
end
|
#create_method ⇒ Object
93
94
95
|
# File 'lib/active_graph/relationship/persistence.rb', line 93
def create_method
self.class.create_method
end
|
#create_model ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'lib/active_graph/relationship/persistence.rb', line 48
def create_model
validate_node_classes!
delete_has_one_rel
rel = _create_rel
return self unless rel.respond_to?(:properties)
init_on_load(rel, from_node, to_node, @type)
true
end
|
#cypher_identifier ⇒ Object
29
30
31
|
# File 'lib/active_graph/relationship/persistence.rb', line 29
def cypher_identifier
@cypher_identifier || :rel
end
|
#delete_has_one_rel ⇒ Object
57
58
59
60
|
# File 'lib/active_graph/relationship/persistence.rb', line 57
def delete_has_one_rel
to_node.delete_reverse_has_one_relationship(self, :in, from_node) if to_node.persisted?
from_node.delete_reverse_has_one_relationship(self, :out, to_node) if from_node.persisted?
end
|
#from_node_identifier ⇒ Object
13
14
15
|
# File 'lib/active_graph/relationship/persistence.rb', line 13
def from_node_identifier
@from_node_identifier || :from_node
end
|
#from_node_identifier=(id) ⇒ Object
21
22
23
|
# File 'lib/active_graph/relationship/persistence.rb', line 21
def from_node_identifier=(id)
@from_node_identifier = id.to_sym
end
|
#query_as(var) ⇒ Object
62
63
64
65
66
|
# File 'lib/active_graph/relationship/persistence.rb', line 62
def query_as(var)
self.class.query_as(neo_id, var)
end
|
#save ⇒ Object
33
34
35
|
# File 'lib/active_graph/relationship/persistence.rb', line 33
def save(*)
create_or_update
end
|
#save!(*args) ⇒ Object
37
38
39
|
# File 'lib/active_graph/relationship/persistence.rb', line 37
def save!(*args)
save(*args) or fail(RelInvalidError, inspect) end
|
#to_node_identifier ⇒ Object
17
18
19
|
# File 'lib/active_graph/relationship/persistence.rb', line 17
def to_node_identifier
@to_node_identifier || :to_node
end
|
#to_node_identifier=(id) ⇒ Object
25
26
27
|
# File 'lib/active_graph/relationship/persistence.rb', line 25
def to_node_identifier=(id)
@to_node_identifier = id.to_sym
end
|