Module: Neo4j::Rails::Persistence
- Extended by:
- ActiveSupport::Concern, TxMethods
- Included in:
- Model, Relationship
- Defined in:
- lib/neo4j/rails/persistence.rb
Overview
Defines the create, delete and update methods.
Defined Under Namespace
Modules: ClassMethods Classes: RecordInvalidError
Instance Method Summary (collapse)
-
- (Boolean) create_or_updating?
Returns if the entity is currently being updated or created.
-
- (Object) delete
Same as #destroy but doesn't run destroy callbacks and doesn't freeze the object.
-
- (Object) destroy
Removes the node from Neo4j and freezes the object.
-
- (Boolean) destroyed?
Returns true if the object was destroyed.
-
- (Object) freeze
Freeze the properties hash.
-
- (Boolean) frozen?
Returns true if the properties hash has been frozen.
-
- (Boolean) new_record?
(also: #new?)
Returns true if the record hasn't been saved to Neo4j yet.
-
- (Boolean) persisted?
Returns true if the record is persisted, i.e.
-
- (Boolean) save
Persist the object to the database.
-
- (Object) save!(*args)
Persist the object to the database.
Methods included from TxMethods
Instance Method Details
- (Boolean) create_or_updating?
Returns if the entity is currently being updated or created
141 142 143 |
# File 'lib/neo4j/rails/persistence.rb', line 141 def create_or_updating? !!@_create_or_updating end |
- (Object) delete
Same as #destroy but doesn't run destroy callbacks and doesn't freeze the object. Creates a new transaction
46 47 48 49 |
# File 'lib/neo4j/rails/persistence.rb', line 46 def delete del unless new_record? || destroyed? set_deleted_properties end |
- (Object) destroy
Removes the node from Neo4j and freezes the object.
39 40 41 42 |
# File 'lib/neo4j/rails/persistence.rb', line 39 def destroy delete freeze end |
- (Boolean) destroyed?
Returns true if the object was destroyed.
53 54 55 |
# File 'lib/neo4j/rails/persistence.rb', line 53 def destroyed? @_deleted || (!new_record? && !self.class.load_entity(neo_id)) end |
- (Object) freeze
Freeze the properties hash.
70 71 72 73 |
# File 'lib/neo4j/rails/persistence.rb', line 70 def freeze @_properties.freeze self end |
- (Boolean) frozen?
Returns true if the properties hash has been frozen.
76 77 78 79 |
# File 'lib/neo4j/rails/persistence.rb', line 76 def frozen? freeze_if_deleted @_properties.frozen? end |
- (Boolean) new_record? Also known as: new?
Returns true if the record hasn't been saved to Neo4j yet.
63 64 65 |
# File 'lib/neo4j/rails/persistence.rb', line 63 def new_record? _java_entity.nil? end |
- (Boolean) persisted?
Returns true if the record is persisted, i.e. it’s not a new record and it was not destroyed
58 59 60 |
# File 'lib/neo4j/rails/persistence.rb', line 58 def persisted? !new_record? && !destroyed? end |
- (Boolean) save
Persist the object to the database. Validations and Callbacks are included by default but validation can be disabled by passing :validate => false to save. Creates a new transaction.
17 18 19 |
# File 'lib/neo4j/rails/persistence.rb', line 17 def save(*) create_or_update end |
- (Object) save!(*args)
Persist the object to the database. Validations and Callbacks are included by default but validation can be disabled by passing :validate => false to #save! Creates a new transaction.
32 33 34 35 36 |
# File 'lib/neo4j/rails/persistence.rb', line 32 def save!(*args) unless save(*args) raise RecordInvalidError.new(self) end end |