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

- (Object) method_missing(method, *args, &block) (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

- (Object) default_sphinx_scope(scope_name = nil)



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

- (Object) sphinx_scope(name, &block)



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

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

- (Object) sphinx_scopes



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

def sphinx_scopes
  @sphinx_scopes ||= {}
end