class Tire::Search::BooleanQuery

Public Class Methods

new(options={}, &block) click to toggle source

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.

# File lib/tire/search/query.rb, line 91
def initialize(options={}, &block)
  @options = options
  @value   = {}
  block.arity < 1 ? self.instance_eval(&block) : block.call(self) if block_given?
end

Public Instance Methods

must(&block) click to toggle source
# File lib/tire/search/query.rb, line 97
def must(&block)
  (@value[:must] ||= []) << Query.new(&block).to_hash
  @value
end
must_not(&block) click to toggle source
# File lib/tire/search/query.rb, line 102
def must_not(&block)
  (@value[:must_not] ||= []) << Query.new(&block).to_hash
  @value
end
should(&block) click to toggle source
# File lib/tire/search/query.rb, line 107
def should(&block)
  (@value[:should] ||= []) << Query.new(&block).to_hash
  @value
end
to_hash() click to toggle source
# File lib/tire/search/query.rb, line 112
def to_hash
  @value.update(@options)
end