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

Returns a new instance of ScopesMask.



4
5
6
# File 'lib/thinking_sphinx/masks/scopes_mask.rb', line 4

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)



49
50
51
# File 'lib/thinking_sphinx/masks/scopes_mask.rb', line 49

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

Instance Method Details

#can_handle?(method) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/thinking_sphinx/masks/scopes_mask.rb', line 8

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

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



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

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

#noneObject Also known as: search_none



29
30
31
# File 'lib/thinking_sphinx/masks/scopes_mask.rb', line 29

def none
  ThinkingSphinx::Search::Merger.new(@search).merge! nil, :none => true
end

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



19
20
21
22
# File 'lib/thinking_sphinx/masks/scopes_mask.rb', line 19

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

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



24
25
26
27
# File 'lib/thinking_sphinx/masks/scopes_mask.rb', line 24

def search_for_ids(query = nil, options = {})
  query, options = nil, query if query.is_a?(Hash)
  search query, options.merge(:ids_only => true)
end