Class: Tire::Search::BoostingQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/tire/search/query.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ BoostingQuery

Returns a new instance of BoostingQuery.



255
256
257
258
259
# File 'lib/tire/search/query.rb', line 255

def initialize(options={}, &block)
  @options = options
  @value   = {}
  block.arity < 1 ? self.instance_eval(&block) : block.call(self) if block_given?
end

Instance Method Details

#negative(&block) ⇒ Object



266
267
268
269
# File 'lib/tire/search/query.rb', line 266

def negative(&block)
  (@value[:negative] ||= []) << Query.new(&block).to_hash
  @value
end

#positive(&block) ⇒ Object



261
262
263
264
# File 'lib/tire/search/query.rb', line 261

def positive(&block)
  (@value[:positive] ||= []) << Query.new(&block).to_hash
  @value
end

#to_hashObject



271
272
273
# File 'lib/tire/search/query.rb', line 271

def to_hash
  @value.update(@options)
end