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 (private)



21
22
23
24
25
26
# File 'lib/thinking_sphinx/scopes.rb', line 21

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



5
6
7
8
9
# File 'lib/thinking_sphinx/scopes.rb', line 5

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



11
12
13
# File 'lib/thinking_sphinx/scopes.rb', line 11

def sphinx_scope(name, &block)
  sphinx_scopes[name] = block
end

#sphinx_scopesObject



15
16
17
# File 'lib/thinking_sphinx/scopes.rb', line 15

def sphinx_scopes
  @sphinx_scopes ||= {}
end