Commit 5058797e by Nikolay Norkin

real_destroy callback

parent df42daa3
......@@ -47,7 +47,7 @@ module Paranoia
module Callbacks
def self.extended(klazz)
klazz.define_callbacks :restore
klazz.define_callbacks :restore, :real_destroy
klazz.define_singleton_method("before_restore") do |*args, &block|
set_callback(:restore, :before, *args, &block)
......@@ -172,6 +172,8 @@ class ActiveRecord::Base
alias :destroy_without_paranoia :destroy
def really_destroy!
transaction do
run_callbacks(:real_destroy) do
dependent_reflections = self.class.reflections.select do |name, reflection|
reflection.options[:dependent] == :destroy
end
......@@ -192,6 +194,8 @@ class ActiveRecord::Base
write_attribute(paranoia_column, current_time_from_proper_timezone)
destroy_without_paranoia
end
end
end
include Paranoia
class_attribute :paranoia_column, :paranoia_sentinel_value
......
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