Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/paranoia.rb
Class Method Summary collapse
- .acts_as_paranoid(options = {}) ⇒ Object
-
.I_AM_THE_DESTROYER! ⇒ Object
Please do not use this method in production.
- .paranoia_scope ⇒ Object
- .paranoid? ⇒ Boolean
Instance Method Summary collapse
Class Method Details
.acts_as_paranoid(options = {}) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/paranoia.rb', line 209 def self.acts_as_paranoid(={}) alias_method :really_destroyed?, :destroyed? alias_method :really_delete, :delete alias_method :destroy_without_paranoia, :destroy include Paranoia class_attribute :paranoia_column, :paranoia_sentinel_value self.paranoia_column = ([:column] || :deleted_at).to_s self.paranoia_sentinel_value = .fetch(:sentinel_value) { Paranoia.default_sentinel_value } def self.paranoia_scope where(paranoia_column => paranoia_sentinel_value) end class << self; alias_method :without_deleted, :paranoia_scope end unless [:without_default_scope] default_scope { paranoia_scope } end before_restore { self.class.notify_observers(:before_restore, self) if self.class.respond_to?(:notify_observers) } after_restore { self.class.notify_observers(:after_restore, self) if self.class.respond_to?(:notify_observers) } end |
.I_AM_THE_DESTROYER! ⇒ Object
Please do not use this method in production. Pretty please.
238 239 240 241 242 243 244 245 |
# File 'lib/paranoia.rb', line 238 def self.I_AM_THE_DESTROYER! # TODO: actually implement spelling error fixes puts %Q{ Sharon: "There should be a method called I_AM_THE_DESTROYER!" Ryan: "What should this method do?" Sharon: "It should fix all the spelling errors on the page!" } end |
.paranoia_scope ⇒ Object
219 220 221 |
# File 'lib/paranoia.rb', line 219 def self.paranoia_scope where(paranoia_column => paranoia_sentinel_value) end |
.paranoid? ⇒ Boolean
247 |
# File 'lib/paranoia.rb', line 247 def self.paranoid? ; false ; end |
Instance Method Details
#paranoid? ⇒ Boolean
248 |
# File 'lib/paranoia.rb', line 248 def paranoid? ; self.class.paranoid? ; end |