52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/caboose/acts/paranoid.rb', line 52
def acts_as_paranoid(options = {})
unless paranoid? class << self
VALID_FIND_OPTIONS << :with_deleted unless VALID_FIND_OPTIONS.include?(:with_deleted)
end
ActiveRecord::Calculations::CALCULATIONS_OPTIONS << :with_deleted unless ActiveRecord::Calculations::CALCULATIONS_OPTIONS.include?(:with_deleted)
cattr_accessor :deleted_attribute
self.deleted_attribute = options[:with] || :deleted_at
alias_method :destroy_without_callbacks!, :destroy_without_callbacks
class << self
alias_method :find_every_with_deleted, :find_every
alias_method :calculate_with_deleted, :calculate
alias_method :delete_all!, :delete_all
end
if ActiveRecord::Base.respond_to?(:named_scope)
named_scope :with_deleted, lambda { |with_deleted| (with_deleted == true) ? { :with_deleted => true } : {} }
end
end
include InstanceMethods
end
|