Commit 9b8158e2 by John Hawthorn

Always return self from touch_paranoia_column

parent b99fd225
...@@ -57,12 +57,11 @@ module Paranoia ...@@ -57,12 +57,11 @@ module Paranoia
end end
def destroy def destroy
callbacks_result = transaction do transaction do
run_callbacks(:destroy) do run_callbacks(:destroy) do
touch_paranoia_column touch_paranoia_column
end end
end end
callbacks_result ? self : false
end end
# As of Rails 4.1.0 +destroy!+ will no longer remove the record from the db # As of Rails 4.1.0 +destroy!+ will no longer remove the record from the db
...@@ -76,8 +75,7 @@ module Paranoia ...@@ -76,8 +75,7 @@ module Paranoia
end end
def delete def delete
return if new_record? touch_paranoia_column
touch_paranoia_column(false)
end end
def restore!(opts = {}) def restore!(opts = {})
...@@ -109,16 +107,15 @@ module Paranoia ...@@ -109,16 +107,15 @@ module Paranoia
# insert time to paranoia column. # insert time to paranoia column.
# @param with_transaction [Boolean] exec with ActiveRecord Transactions. # @param with_transaction [Boolean] exec with ActiveRecord Transactions.
def touch_paranoia_column(with_transaction=false) def touch_paranoia_column(with_transaction=false)
return self if really_destroyed? || new_record?
# This method is (potentially) called from really_destroy # This method is (potentially) called from really_destroy
# The object the method is being called on may be frozen # The object the method is being called on may be frozen
# Let's not touch it if it's frozen. # Let's not touch it if it's frozen.
unless self.frozen? unless self.frozen?
if with_transaction touch(paranoia_column)
with_transaction_returning_status { touch(paranoia_column) }
else
touch(paranoia_column)
end
end end
self
end end
# restore associated records that have been soft deleted when # restore associated records that have been soft deleted when
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment