Sha256: fe51631271144e6f3913ab51da164d73d47004ec56094a12c555cfd5de9a1e0d

Contents?: true

Size: 959 Bytes

Versions: 7

Compression:

Stored size: 959 Bytes

Contents

module Sunspot
  module DSL
    # 
    # This tiny DSL class implements the DSL for the FieldQuery.facet
    # method.
    #
    class QueryFacet
      def initialize(query_facet, setup) #:nodoc:
        @query_facet, @setup = query_facet, setup
      end

      # 
      # 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.
      #
      def row(label, &block)
        Scope.new(@query_facet.add_row(label), @setup).instance_eval(&block)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
sunspot-0.10.5 lib/sunspot/dsl/query_facet.rb
sunspot-0.10.4 lib/sunspot/dsl/query_facet.rb
kuahyeow-sunspot-0.10.3 lib/sunspot/dsl/query_facet.rb
sunspot-0.10.3 lib/sunspot/dsl/query_facet.rb
sunspot-0.10.2 lib/sunspot/dsl/query_facet.rb
sunspot-0.10.1 lib/sunspot/dsl/query_facet.rb
sunspot-0.10.0 lib/sunspot/dsl/query_facet.rb