Class: Sunspot::DSL::QueryFacet
- Inherits:
-
Object
- Object
- Sunspot::DSL::QueryFacet
- Defined in:
- lib/sunspot/dsl/query_facet.rb
Overview
This tiny DSL class implements the DSL for the FieldQuery.facet method.
Instance Method Summary collapse
-
#initialize(query_facet) ⇒ QueryFacet
constructor
:nodoc:.
-
#row(label, &block) ⇒ Object
Add a row to this query facet.
Constructor Details
#initialize(query_facet) ⇒ QueryFacet
:nodoc:
8 9 10 |
# File 'lib/sunspot/dsl/query_facet.rb', line 8 def initialize(query_facet) #:nodoc: @query_facet = query_facet end |
Instance Method Details
#row(label, &block) ⇒ Object
Add a row to this query facet. The label argument can be anything; it’s simply the value that’s passed into the Sunspot::QueryFacetRow object corresponding to the row that’s created. Use whatever seems most intuitive.
The block is evaluated in the context of a Sunspot::DSL::Scope, meaning any restrictions can be placed on the documents matching this facet row.
Parameters
- label<Object>
-
An object used to identify this facet row in the results.
26 27 28 |
# File 'lib/sunspot/dsl/query_facet.rb', line 26 def row(label, &block) Scope.new(@query_facet.add_row(label)).instance_eval(&block) end |