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.



165
166
167
168
169
# File 'lib/tire/search/query.rb', line 165

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



171
172
173
174
# File 'lib/tire/search/query.rb', line 171

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

#to_hashObject



176
177
178
# File 'lib/tire/search/query.rb', line 176

def to_hash
  @value.update(@options)
end

#to_jsonObject



180
181
182
# File 'lib/tire/search/query.rb', line 180

def to_json
  to_hash.to_json
end