| Module | ScopedSearch::ClassMethods |
| In: |
lib/scoped_search.rb
|
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.
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 27
27: def scoped_search(*definitions)
28: @scoped_search ||= ScopedSearch::Definition.new(self)
29: definitions.each do |definition|
30: if definition[:on].kind_of?(Array)
31: definition[:on].each { |field| @scoped_search.define(definition.merge(:on => field)) }
32: else
33: @scoped_search.define(definition)
34: end
35: end
36: return @scoped_search
37: end