module Mongoid::Persistable::Destroyable

Defines behaviour for persistence operations that destroy documents.

@since 4.0.0

Public Instance Methods

destroy(options = {}) click to toggle source

Remove the document from the database with callbacks.

@example Destroy a document.

document.destroy

@param [ Hash ] options Options to pass to destroy.

@return [ true, false ] True if successful, false if not.

@since 1.0.0

# File lib/mongoid/persistable/destroyable.rb, line 21
def destroy(options = {})
  self.flagged_for_destroy = true
  result = run_callbacks(:destroy) { delete(options) }
  self.flagged_for_destroy = false
  result
end