Sha256: 8cbd326f4fdc9177765c475d3354362474c98745ff828007d512255d2883875d

Contents?: true

Size: 717 Bytes

Versions: 43

Compression:

Stored size: 717 Bytes

Contents

# -*- encoding : utf-8 -*-
class Search < ActiveRecord::Base

  belongs_to :user

  serialize :query_params

  if Rails::VERSION::MAJOR < 4
    attr_accessible :query_params 
  
    scope :none, where(:id => nil).where("id IS NOT ?", nil)
  end

  # 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

43 entries across 43 versions & 1 rubygems

Version Path
blacklight-5.5.0 app/models/search.rb
blacklight-5.4.0 app/models/search.rb
blacklight-5.4.0.rc1 app/models/search.rb
blacklight-5.3.0 app/models/search.rb
blacklight-5.0.3 app/models/search.rb
blacklight-5.1.1 app/models/search.rb
blacklight-5.2.0 app/models/search.rb
blacklight-5.1.0 app/models/search.rb
blacklight-5.0.2 app/models/search.rb
blacklight-5.0.1 app/models/search.rb
blacklight-5.0.0 app/models/search.rb
blacklight-4.7.0 app/models/search.rb
blacklight-4.7.0.pre1 app/models/search.rb
blacklight-5.0.0.pre4 app/models/search.rb
blacklight-4.6.3 app/models/search.rb
blacklight-5.0.0.pre3 app/models/search.rb
blacklight-4.6.2 app/models/search.rb
blacklight-5.0.0.pre2 app/models/search.rb
blacklight-4.6.1 app/models/search.rb
blacklight-5.0.0.pre1 app/models/search.rb