Class: Tire::Search::BooleanQuery
- Inherits:
-
Object
- Object
- Tire::Search::BooleanQuery
- Defined in:
- lib/tire/search/query.rb
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ BooleanQuery
constructor
TODO: Try to get rid of multiple ‘should`, `must`, etc invocations, and wrap queries directly:.
- #must(&block) ⇒ Object
- #must_not(&block) ⇒ Object
- #should(&block) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ BooleanQuery
TODO: Try to get rid of multiple ‘should`, `must`, etc invocations, and wrap queries directly:
boolean do
should do
string 'foo'
string 'bar'
end
end
Inherit from Query, implement ‘encode` method there, and overload it here, so it puts queries in an Array instead of hash.
96 97 98 99 100 |
# File 'lib/tire/search/query.rb', line 96 def initialize(={}, &block) @options = @value = {} block.arity < 1 ? self.instance_eval(&block) : block.call(self) if block_given? end |
Instance Method Details
#must(&block) ⇒ Object
102 103 104 105 |
# File 'lib/tire/search/query.rb', line 102 def must(&block) (@value[:must] ||= []) << Query.new(&block).to_hash @value end |
#must_not(&block) ⇒ Object
107 108 109 110 |
# File 'lib/tire/search/query.rb', line 107 def must_not(&block) (@value[:must_not] ||= []) << Query.new(&block).to_hash @value end |
#should(&block) ⇒ Object
112 113 114 115 |
# File 'lib/tire/search/query.rb', line 112 def should(&block) (@value[:should] ||= []) << Query.new(&block).to_hash @value end |
#to_hash ⇒ Object
117 118 119 |
# File 'lib/tire/search/query.rb', line 117 def to_hash @value.update(@options) end |