Sha256: e1439483e52034a2246efafddaf2ae1aad7e7b30969cf8e9d6befeb77bb17cb3

Contents?: true

Size: 800 Bytes

Versions: 9

Compression:

Stored size: 800 Bytes

Contents

module Sunspot
  # 
  # InstantiatedFacetRow objects represent a single value for an instantiated
  # facet. As well as the usual FacetRow methods, InstantedFacetRow objects
  # provide access to the persistent object referenced by the row's value.
  #
  class InstantiatedFacetRow < FacetRow
    attr_writer :instance #:nodoc:

    def initialize(value, count, facet) #:nodoc:
      super(value, count)
      @facet = facet
    end

    #
    # Get the persistent object referenced by this row's value. Instances are
    # batch-lazy-loaded, which means that for a given facet, all of the
    # instances are loaded the first time any row's instance is requested.
    #
    def instance
      unless defined?(@instance)
        @facet.populate_instances!
      end
      @instance
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
benjaminkrause-sunspot-0.9.7 lib/sunspot/instantiated_facet_row.rb
benjaminkrause-sunspot-0.9.8 lib/sunspot/instantiated_facet_row.rb
sunspot-0.10.5 lib/sunspot/instantiated_facet_row.rb
sunspot-0.10.4 lib/sunspot/instantiated_facet_row.rb
kuahyeow-sunspot-0.10.3 lib/sunspot/instantiated_facet_row.rb
sunspot-0.10.3 lib/sunspot/instantiated_facet_row.rb
sunspot-0.10.2 lib/sunspot/instantiated_facet_row.rb
sunspot-0.10.1 lib/sunspot/instantiated_facet_row.rb
sunspot-0.10.0 lib/sunspot/instantiated_facet_row.rb