Methods

Files

ScopedSearch::ClassMethods

The ClassMethods module will be included into the ActiveRecord::Base class to add the ActiveRecord::Base.scoped_search method and the ActiveRecord::Base.search_for named scope.

Public Instance Methods

scoped_search(*definitions) click to toggle source

Export the scoped_search method fo defining the search options. This method will create a definition instance for the class if it does not yet exist, and use the object as block argument and retun value.

# File lib/scoped_search.rb, line 23
def scoped_search(*definitions)
  @scoped_search ||= ScopedSearch::Definition.new(self)
  definitions.each do |definition|
    if definition[:on].kind_of?(Array)
      definition[:on].each { |field| @scoped_search.define(definition.merge(:on => field)) }
    else
      @scoped_search.define(definition)
    end
  end
  return @scoped_search
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.