模块:Mongoid::Persistable::Destroyable
Overview
定义销毁文档的持久性操作的行为。
在命名空间下定义
模块: 类方法
实例方法摘要折叠
-
#destroy (options = nil) ⇒ true | false
使用回调从数据库中删除文档。
-
#销毁! (options = {}) ⇒ true
使用回调从数据库中删除文档。
实例方法详细信息
#destroy (options = nil) ⇒ true | false
使用回调从数据库中删除文档。
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mongoid/persistable/destroyable.rb', line 23 def 销毁( = nil) 提高 Errors::ReadonlyDocument.new(self.class) if 只读? self.flagged_for_destroy = true 结果 = run_callbacks(:提交, skip_if: -> { in_transaction? }) do run_callbacks(:destroy) do if catch(:abort) { apply_destroy_dependencies! } 删除( || {}).点击 do |res| if res && in_transaction? 线程化.add_modified_document(_session, self) end end else false end end end self.flagged_for_destroy = false 结果 end |
#销毁! (options = {}) ⇒ true
使用回调从数据库中删除文档。 如果未销毁文档,则会引发错误。
59 60 61 |
# File 'lib/mongoid/persistable/destroyable.rb', line 59 def 销毁!( = {}) 销毁() || 提高(Errors::DocumentNotDestroyed.new(_id, self.class)) end |