Module: Caboose::Acts::Paranoid::InstanceMethods::ClassMethods

Defined in:
lib/caboose/acts/paranoid.rb

Instance Method Summary collapse

Instance Method Details

#calculate(*args) ⇒ Object



102
103
104
# File 'lib/caboose/acts/paranoid.rb', line 102

def calculate(*args)
  with_deleted_scope { calculate_with_deleted(*args) }
end

#count(*args) ⇒ Object



98
99
100
# File 'lib/caboose/acts/paranoid.rb', line 98

def count(*args)
  with_deleted_scope { count_with_deleted(*args) }
end

#count_with_deleted(*args) ⇒ Object



94
95
96
# File 'lib/caboose/acts/paranoid.rb', line 94

def count_with_deleted(*args)
  calculate_with_deleted(:count, *construct_count_options_from_args(*args))
end

#delete_all(conditions = nil) ⇒ Object



106
107
108
# File 'lib/caboose/acts/paranoid.rb', line 106

def delete_all(conditions = nil)
  self.update_all ["#{self.deleted_attribute} = ?", current_time], conditions
end

#exists?(*args) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/caboose/acts/paranoid.rb', line 90

def exists?(*args)
  with_deleted_scope { exists_with_deleted?(*args) }
end

#find_with_deleted(*args) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/caboose/acts/paranoid.rb', line 77

def find_with_deleted(*args)
  options = args.extract_options!
  validate_find_options(options)
  set_readonly_option!(options)
  options[:with_deleted] = true # yuck!

  case args.first
    when :first then find_initial(options)
    when :all   then find_every(options)
    else             find_from_ids(args, options)
  end
end