Class: Tire::Search::NestedQuery

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of NestedQuery.



232
233
234
235
236
# File 'lib/tire/search/query.rb', line 232

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



238
239
240
241
# File 'lib/tire/search/query.rb', line 238

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

#to_hashObject



243
244
245
# File 'lib/tire/search/query.rb', line 243

def to_hash
  @value.update(@options)
end

#to_jsonObject



247
248
249
# File 'lib/tire/search/query.rb', line 247

def to_json
  to_hash.to_json
end