Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't override mongoid original update. #40

Merged
merged 1 commit into from
Sep 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/mongoid/paranoia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -193,10 +193,10 @@ def paranoid_field
embedded? ? "#{atomic_position}.#{field}" : field
end

# Update value in the collection.
# Update value in the collection (compatibility layer 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)
Expand Down