module CombiSearch::ClassMethods

Public Instance Methods

combi_search_scope(name, options = {}) click to toggle source

Method to add a combi_search_scope for a specific model Usage:

combi_search_scope :public, on: [:name, :title, :something_else]
# File lib/combi_search.rb, line 93
def combi_search_scope(name, options = {})
  if options.nil? || options[:on].nil? || !(options[:on].class == Symbol || options[:on].class == Array)
    raise "No attributes defined for combi_search_scope: #{:name}, in: #{self}"
  end

  if !self.combi_search_scopes[name].is_a?(Array)
    self.combi_search_scopes[name]=[]
  end
  self.combi_search_scopes[name].push(options)
end