3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/acts_as_paranoid/relation.rb', line 3
def self.included(base)
base.class_eval do
def paranoid?
klass.try(:paranoid?) ? true : false
end
def paranoid_deletion_attributes
{ klass.paranoid_column => klass.delete_now_value }
end
alias_method :orig_delete_all, :delete_all
def delete_all!(conditions = nil)
if conditions
where(conditions).delete_all!
else
orig_delete_all
end
end
def delete_all(conditions = nil)
if paranoid?
update_all(paranoid_deletion_attributes, conditions)
else
delete_all!(conditions)
end
end
def destroy!(id_or_array)
where(primary_key => id_or_array).orig_delete_all
end
end
end
|