Method: Sunspot::DSL::Scope#all_of

Defined in:
lib/sunspot/dsl/scope.rb

#all_of(&block) ⇒ Object

Create a conjunction, scoping the results to documents that match all of the enclosed restrictions. When called from the top level of a search block, this has no effect, but can be useful for grouping a conjunction inside a disjunction.

Example

Sunspot.search(Post) do
  any_of do
    with(:blog_id, 1)
    all_of do
      with(:blog_id, 2)
      with(:category_ids, 3)
    end
  end
end


164
165
166
# File 'lib/sunspot/dsl/scope.rb', line 164

def all_of(&block)
  Util.instance_eval_or_call(Scope.new(@query.add_conjunction), &block)
end