Class: Tire::Search::DisMaxQuery

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of DisMaxQuery.



213
214
215
216
217
# File 'lib/tire/search/query.rb', line 213

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

Instance Method Details

#query(&block) ⇒ Object



219
220
221
222
# File 'lib/tire/search/query.rb', line 219

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

#to_hashObject



224
225
226
# File 'lib/tire/search/query.rb', line 224

def to_hash
  @value.update(@options)
end

#to_json(options = {}) ⇒ Object



228
229
230
# File 'lib/tire/search/query.rb', line 228

def to_json(options={})
  to_hash.to_json
end