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

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

Instance Method Summary collapse

Instance Method Details

#calculate(*args) ⇒ Object



109
110
111
# File 'lib/caboose/acts/paranoid.rb', line 109

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

#count(*args) ⇒ Object



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

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

#count_with_deleted(*args) ⇒ Object



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

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

#delete_all(conditions = nil) ⇒ Object



113
114
115
# File 'lib/caboose/acts/paranoid.rb', line 113

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

#exists?(*args) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#find_with_deleted(*args) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/caboose/acts/paranoid.rb', line 84

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