Module: ThinkingSphinx::Scopes::ClassMethods
- Defined in:
- lib/thinking_sphinx/scopes.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/thinking_sphinx/scopes.rb', line 23
def method_missing(method, *args, &block)
return super unless sphinx_scopes.keys.include?(method)
query, options = sphinx_scopes[method].call(*args)
search query, (options || {})
end
|
Instance Method Details
#default_sphinx_scope(scope_name = nil) ⇒ Object
7
8
9
10
11
|
# File 'lib/thinking_sphinx/scopes.rb', line 7
def default_sphinx_scope(scope_name = nil)
return @default_sphinx_scope unless scope_name
@default_sphinx_scope = scope_name
end
|
#sphinx_scope(name, &block) ⇒ Object
13
14
15
|
# File 'lib/thinking_sphinx/scopes.rb', line 13
def sphinx_scope(name, &block)
sphinx_scopes[name] = block
end
|
#sphinx_scopes ⇒ Object
17
18
19
|
# File 'lib/thinking_sphinx/scopes.rb', line 17
def sphinx_scopes
@sphinx_scopes ||= {}
end
|