From 7833aad8d8372705c32be3b4fa18a7bbc96553f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?= Date: Mon, 28 Sep 2015 13:41:38 +0200 Subject: [PATCH] Don't override mongoid original update. --- lib/mongoid/paranoia.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mongoid/paranoia.rb b/lib/mongoid/paranoia.rb index 787e230..c28f474 100644 --- a/lib/mongoid/paranoia.rb +++ b/lib/mongoid/paranoia.rb @@ -98,7 +98,7 @@ def persisted? def remove_with_paranoia(options = {}) cascade! time = self.deleted_at = Time.now - update("$set" => { paranoid_field => time }) + _paranoia_update("$set" => { paranoid_field => time }) @destroyed = true true end @@ -145,7 +145,7 @@ def destroyed? # @since 1.0.0 def restore(opts = {}) run_callbacks(:restore) do - update("$unset" => { paranoid_field => true }) + _paranoia_update("$unset" => { paranoid_field => true }) attributes.delete("deleted_at") @destroyed = false restore_relations if opts[:recursive] @@ -193,10 +193,10 @@ def paranoid_field embedded? ? "#{atomic_position}.#{field}" : field end - # Update value in the collection. + # Update value in the collection compatibility layor for Mongoid 4/5. # # @return [ Object ] Update result. - def update(value) + def _paranoia_update(value) query = paranoid_collection.find(atomic_selector) if Mongoid::Compatibility::Version.mongoid5? query.update_one(value)