Class: ThinkingSphinx::Masks::ScopesMask

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

Instance Method Summary collapse

Constructor Details

#initialize(search) ⇒ 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

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

#can_handle?(method) ⇒ 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

#facets(query = nil, options = {}) ⇒ Object



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

#search(query = nil, options = {}) ⇒ Object



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