Sha256: 1f41d7102f5ac9cdf0692dd4947b75899e64a4ebcd2a65c5aa3df9013f5f5f2e

Contents?: true

Size: 647 Bytes

Versions: 6

Compression:

Stored size: 647 Bytes

Contents

# -*- encoding : utf-8 -*-
class Search < ActiveRecord::Base
  
  belongs_to :user
  
  serialize :query_params
  attr_accessible :query_params if Rails::VERSION::MAJOR < 4
  
  # A Search instance is considered a saved search if it has a user_id.
  def saved?
    self.user_id?
  end
  
  # delete old, unsaved searches
  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
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blacklight-4.4.2 app/models/search.rb
blacklight-4.4.1 app/models/search.rb
blacklight-4.4.0 app/models/search.rb
blacklight-4.3.0 app/models/search.rb
blacklight-4.2.2 app/models/search.rb
blacklight-4.2.1 app/models/search.rb