class ActiveRecord::Base

Public Class Methods

I_AM_THE_DESTROYER!() click to toggle source

Please do not use this method in production. Pretty please.

# File lib/paranoia.rb, line 135
  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
acts_as_paranoid(options={}) click to toggle source
# File lib/paranoia.rb, line 115
def self.acts_as_paranoid(options={})
  alias :really_destroy! :destroy
  alias :destroy! :destroy
  alias :delete! :delete
  include Paranoia
  class_attribute :paranoia_column

  self.paranoia_column = options[:column] || :deleted_at
  default_scope { where(paranoia_column => nil) }

  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
paranoid?() click to toggle source
# File lib/paranoia.rb, line 144
def self.paranoid? ; false ; end

Public Instance Methods

paranoid?() click to toggle source
# File lib/paranoia.rb, line 145
def paranoid? ; self.class.paranoid? ; end
persisted?() click to toggle source

Override the persisted method to allow for the paranoia gem. If a paranoid record is selected, then we only want to check if it's a new record, not if it is “destroyed”.

Calls superclass method
# File lib/paranoia.rb, line 150
def persisted?
  paranoid? ? !new_record? : super
end

Private Instance Methods

paranoia_column() click to toggle source
# File lib/paranoia.rb, line 156
def paranoia_column
  self.class.paranoia_column
end