Class: Search

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/search.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) delete_old_searches(days_old)

delete old, unsaved searches

Raises:

  • (ArgumentError)


20
21
22
23
24
# File 'app/models/search.rb', line 20

def self.delete_old_searches(days_old)
  raise ArgumentError.new('days_old is expected to be a number') unless days_old.is_a?(Numeric)
  raise ArgumentError.new('days_old is expected to be greater than 0') if days_old <= 0
  self.destroy_all(['created_at < ? AND user_id IS NULL', Date.today - days_old])
end

Instance Method Details

- (Boolean) saved?

A Search instance is considered a saved search if it has a user_id.



15
16
17
# File 'app/models/search.rb', line 15

def saved?
  self.user_id?
end