Commit f6448c4a by John Hawthorn

Add paranoia_{delete,destroy} aliases

This should help users be more explicit about what action they want to
perform. My hope is that this will also make it easier to migrate off of
paranoia.
parent c98ad454
...@@ -52,7 +52,7 @@ module Paranoia ...@@ -52,7 +52,7 @@ module Paranoia
end end
end end
def destroy def paranoia_destroy
transaction do transaction do
run_callbacks(:destroy) do run_callbacks(:destroy) do
@_disable_counter_cache = deleted? @_disable_counter_cache = deleted?
...@@ -69,8 +69,9 @@ module Paranoia ...@@ -69,8 +69,9 @@ module Paranoia
end end
end end
end end
alias_method :destroy, :paranoia_destroy
def delete def paranoia_delete
raise ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly? raise ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
if persisted? if persisted?
# if a transaction exists, add the record so that after_commit # if a transaction exists, add the record so that after_commit
...@@ -82,6 +83,7 @@ module Paranoia ...@@ -82,6 +83,7 @@ module Paranoia
end end
self self
end end
alias_method :delete, :paranoia_delete
def restore!(opts = {}) def restore!(opts = {})
self.class.transaction do self.class.transaction do
......
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