Class: ThinkingSphinx::Search::Merger

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/search/merger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(search) ⇒ Merger

Returns a new instance of Merger



4
5
6
# File 'lib/thinking_sphinx/search/merger.rb', line 4

def initialize(search)
  @search = search
end

Instance Attribute Details

#searchObject (readonly)

Returns the value of attribute search



2
3
4
# File 'lib/thinking_sphinx/search/merger.rb', line 2

def search
  @search
end

Instance Method Details

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



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/thinking_sphinx/search/merger.rb', line 8

def merge!(query = nil, options = {})
  query, options = nil, query if query.is_a?(Hash)
  @search.query  = query unless query.nil?

  options.each do |key, value|
    case key
    when :conditions, :with, :without, :with_all, :without_all
      @search.options[key] ||= {}
      @search.options[key].merge! value
    when :without_ids, :classes
      @search.options[key] ||= []
      @search.options[key] += value
      @search.options[key].uniq!
    else
      @search.options[key] = value
    end
  end

  @search
end