Class: Sunspot::DSL::QueryFacet
- Inherits:
-
Object
- Object
- Sunspot::DSL::QueryFacet
- Defined in:
- sunspot/lib/sunspot/dsl/query_facet.rb
Overview
This tiny DSL class implements the DSL for the FieldQuery.facet method.
Instance Method Summary (collapse)
-
- (QueryFacet) initialize(query, setup, facet)
constructor
:nodoc:.
-
- (Object) row(label, &block)
Add a row to this query facet.
Constructor Details
- (QueryFacet) initialize(query, setup, facet)
:nodoc:
8 9 10 |
# File 'sunspot/lib/sunspot/dsl/query_facet.rb', line 8 def initialize(query, setup, facet) #:nodoc: @query, @setup, @facet = query, setup, facet end |
Instance Method Details
- (Object) row(label, &block)
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 | An object used to identify this facet row in the results. |
26 27 28 29 30 31 32 33 |
# File 'sunspot/lib/sunspot/dsl/query_facet.rb', line 26 def row(label, &block) query_facet = Sunspot::Query::QueryFacet.new Sunspot::Util.instance_eval_or_call( Scope.new(@query.add_query_facet(query_facet), @setup), &block ) @facet.add_row(label, query_facet.to_boolean_phrase) end |