diff --git a/vendor/plugins/is_paranoid/lib/is_paranoid.rb b/vendor/plugins/is_paranoid/lib/is_paranoid.rb index 7054937bc0..c76b5898c2 100644 --- a/vendor/plugins/is_paranoid/lib/is_paranoid.rb +++ b/vendor/plugins/is_paranoid/lib/is_paranoid.rb @@ -16,8 +16,12 @@ module ClassMethods # end def is_paranoid unless included_modules.include?(InstanceMethods) - extend SingletonMethods - include InstanceMethods + # Override the default destroy to allow us to flag deleted_at. + # This preserves the before_destroy and after_destroy callbacks. + # Because this is also called internally by Model.destroy_all and + # the Model.destroy(id), we don't need to specify those methods + # separately. + alias_method :destroy!, :destroy # This is the real magic. All calls made to this model will # append the conditions deleted_at => nil. Exceptions require @@ -25,12 +29,8 @@ def is_paranoid # self.count_with_destroyed, and self.find_with_destroyed ) default_scope where(:deleted_at => nil) - # Override the default destroy to allow us to flag deleted_at. - # This preserves the before_destroy and after_destroy callbacks. - # Because this is also called internally by Model.destroy_all and - # the Model.destroy(id), we don't need to specify those methods - # separately. - alias_method :destroy!, :destroy + include InstanceMethods + extend SingletonMethods end end end