Class: ThinkingSphinx::Masks::ScopesMask

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/masks/scopes_mask.rb

Instance Method Summary (collapse)

Constructor Details

- (ScopesMask) initialize(search)

Returns a new instance of ScopesMask



2
3
4
# File 'lib/thinking_sphinx/masks/scopes_mask.rb', line 2

def initialize(search)
  @search = search
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method, *args, &block) (private)



36
37
38
# File 'lib/thinking_sphinx/masks/scopes_mask.rb', line 36

def method_missing(method, *args, &block)
  apply_scope method, *args
end

Instance Method Details

- (Boolean) can_handle?(method)

Returns:

  • (Boolean)


6
7
8
# File 'lib/thinking_sphinx/masks/scopes_mask.rb', line 6

def can_handle?(method)
  public_methods(false).include?(method) || can_apply_scope?(method)
end

- (Object) facets(query = nil, options = {})



10
11
12
13
14
15
# File 'lib/thinking_sphinx/masks/scopes_mask.rb', line 10

def facets(query = nil, options = {})
  search = ThinkingSphinx.facets query, options
  ThinkingSphinx::Search::Merger.new(search).merge!(
    @search.query, @search.options
  )
end

- (Object) search(query = nil, options = {})



17
18
19
20
# File 'lib/thinking_sphinx/masks/scopes_mask.rb', line 17

def search(query = nil, options = {})
  query, options = nil, query if query.is_a?(Hash)
  ThinkingSphinx::Search::Merger.new(@search).merge! query, options
end