Method: CouchbaseOrm::Persistence#destroy
- Defined in:
- lib/couchbase-orm/persistence.rb
#destroy(with_cas: false, **options) ⇒ Object Also known as: destroy!
Deletes the record in the database and freezes this instance to reflect that no changes should be made (since they can’t be persisted).
There’s a series of callbacks associated with #destroy.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/couchbase-orm/persistence.rb', line 126 def destroy(with_cas: false, **) return self if destroyed? raise 'model not persisted' unless persisted? run_callbacks :destroy do destroy_associations! [:cas] = @__metadata__.cas if with_cas CouchbaseOrm.logger.debug "Data - Destroy #{id}" self.class.collection.remove(id, **) self.id = nil clear_changes_information @destroyed = true freeze end end |