Module: Neo4j::Rails::NodePersistence
Instance Method Summary (collapse)
- - (Object) create
- - (Object) freeze_if_deleted
- - (Object) initialize(attributes = nil)
-
- (Object) reload(options = nil)
Reload the object from the DB.
- - (Object) reload_from_database
- - (Object) update
Methods included from TxMethods
Instance Method Details
- (Object) create
12 13 14 15 16 17 18 19 20 |
# File 'lib/neo4j/rails/node_persistance.rb', line 12 def create node = Neo4j::Node.new init_on_load(node) Neo4j::IdentityMap.add(node, self) init_on_create write_changed_relationships clear_relationships true end |
- (Object) freeze_if_deleted
44 45 46 47 48 49 50 51 52 |
# File 'lib/neo4j/rails/node_persistance.rb', line 44 def freeze_if_deleted unless new_record? Neo4j::IdentityMap.remove_node_by_id(neo_id) unless self.class.load_entity(neo_id) set_deleted_properties freeze end end end |
- (Object) initialize(attributes = nil)
6 7 8 9 |
# File 'lib/neo4j/rails/node_persistance.rb', line 6 def initialize(attributes = nil) initialize_relationships initialize_attributes(attributes) end |
- (Object) reload(options = nil)
Reload the object from the DB
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/neo4j/rails/node_persistance.rb', line 30 def reload( = nil) # Can't reload a none persisted node return self if new_record? clear_changes clear_relationships clear_composition_cache reset_attributes unless reload_from_database set_deleted_properties freeze end self end |
- (Object) reload_from_database
54 55 56 57 58 59 60 |
# File 'lib/neo4j/rails/node_persistance.rb', line 54 def reload_from_database Neo4j::IdentityMap.remove_node_by_id(neo_id) if reloaded = self.class.load_entity(neo_id) send(:attributes=, reloaded.attributes, false) end reloaded end |
- (Object) update
22 23 24 25 26 27 |
# File 'lib/neo4j/rails/node_persistance.rb', line 22 def update super write_changed_relationships clear_relationships true end |