Sha256: 8f088422215292d80ff70f86bf1774f17687daa659587f3814c1a0c495ca1e9b

Contents?: true

Size: 1.15 KB

Versions: 25

Compression:

Stored size: 1.15 KB

Contents

module Sunspot
  module DSL
    # 
    # This tiny DSL class implements the DSL for the FieldQuery.facet
    # method.
    #
    class QueryFacet
      def initialize(query, setup, facet, options) #:nodoc:
        @query, @setup, @facet, @options = query, setup, facet, options
      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)
        query_facet = Sunspot::Query::QueryFacet.new(@options)
        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
    end
  end
end

Version data entries

25 entries across 25 versions & 4 rubygems

Version Path
sunspot-2.7.1 lib/sunspot/dsl/query_facet.rb
sunspot-2.7.0 lib/sunspot/dsl/query_facet.rb
sunspot-2.6.0 lib/sunspot/dsl/query_facet.rb
sunspot-2.5.0 lib/sunspot/dsl/query_facet.rb
sunspot-2.4.0 lib/sunspot/dsl/query_facet.rb
sunspot-2.3.0 lib/sunspot/dsl/query_facet.rb
sunspot-2.2.8 lib/sunspot/dsl/query_facet.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/sunspot-2.2.7/lib/sunspot/dsl/query_facet.rb
sunspot-2.2.7 lib/sunspot/dsl/query_facet.rb
sunspot-2.2.6 lib/sunspot/dsl/query_facet.rb
sunspot-2.2.5 lib/sunspot/dsl/query_facet.rb
sunspot-2.2.4 lib/sunspot/dsl/query_facet.rb
sunspot-2.2.3 lib/sunspot/dsl/query_facet.rb
sunspot-2.2.2 lib/sunspot/dsl/query_facet.rb
sunspot-2.2.1 lib/sunspot/dsl/query_facet.rb
sunspot-2.2.0 lib/sunspot/dsl/query_facet.rb
sunspot-2.1.1 lib/sunspot/dsl/query_facet.rb
sunspot-2.1.0 lib/sunspot/dsl/query_facet.rb
sunspot-2.0.0 lib/sunspot/dsl/query_facet.rb
sunspot-2.0.0.pre.130115 lib/sunspot/dsl/query_facet.rb