Class: ThinkingSphinx::Search::Merger
- Inherits:
-
Object
- Object
- ThinkingSphinx::Search::Merger
- Defined in:
- lib/thinking_sphinx/search/merger.rb
Instance Attribute Summary collapse
-
#search ⇒ Object
readonly
Returns the value of attribute search.
Instance Method Summary collapse
-
#initialize(search) ⇒ Merger
constructor
A new instance of Merger.
- #merge!(query = nil, options = {}) ⇒ Object
Constructor Details
#initialize(search) ⇒ Merger
Returns a new instance of Merger.
6 7 8 |
# File 'lib/thinking_sphinx/search/merger.rb', line 6 def initialize(search) @search = search end |
Instance Attribute Details
#search ⇒ Object (readonly)
Returns the value of attribute search.
4 5 6 |
# File 'lib/thinking_sphinx/search/merger.rb', line 4 def search @search end |
Instance Method Details
#merge!(query = nil, options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/thinking_sphinx/search/merger.rb', line 10 def merge!(query = nil, = {}) if search.populated? raise ThinkingSphinx::PopulatedResultsError, 'This search request has already been made - you can no longer modify it.' end query, = nil, query if query.is_a?(Hash) @search.query = query unless query.nil? .each do |key, value| case key when :conditions, :with, :without, :with_all, :without_all @search.[key] ||= {} @search.[key].merge! value when :without_ids, :classes @search.[key] ||= [] @search.[key] += value @search.[key].uniq! else @search.[key] = value end end @search end |