module Deleteable

Public Class Methods

included(receiver) click to toggle source
# File lib/deleteable.rb, line 3
def self.included(receiver)
  receiver.extend ClassMethods
  receiver.class_eval do
    default_scope where("deleted_at IS NULL")
  end
end

Public Instance Methods

delete() click to toggle source
# File lib/deleteable.rb, line 14
def delete
  update_attribute(:deleted_at,Time.now)
end
is_deleted?() click to toggle source
# File lib/deleteable.rb, line 10
def is_deleted?
  !deleted_at.nil?
end
undelete() click to toggle source
# File lib/deleteable.rb, line 18
def undelete
  update_attribute(:deleted_at,nil)
end