Sha256: e85e7ae757184822ab346fcb79d426394170a340778f71ccf02fa82fee7ca683

Contents?: true

Size: 970 Bytes

Versions: 3

Compression:

Stored size: 970 Bytes

Contents

class Blacklight::SolrResponse::GroupResponse

  include Blacklight::SolrResponse::PaginationMethods

  attr_reader :key, :group, :response

  def initialize key, group, response
    @key = key
    @group = group
    @response = response
  end

  alias_method :group_field, :key

  def groups
    @groups ||= group["groups"].map do |g|
      Blacklight::SolrResponse::Group.new g[:groupValue], g, self
    end
  end

  def group_limit
    params.fetch(:'group.limit', 1).to_s.to_i
  end

  def total
    # ngroups is only available in Solr 4.1+
    # fall back on the number of facet items for that field?
    (group["ngroups"] || (response.aggregations[key] || []).length).to_s.to_i
  end
    
  def start
    params[:start].to_s.to_i
  end

  def method_missing meth, *args, &block

    if response.respond_to? meth
      response.send(meth, *args, &block)
    else
      super
    end

  end

  def respond_to? meth
    response.respond_to?(meth) || super
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-5.15.0 lib/blacklight/solr_response/group_response.rb
blacklight-5.14.0 lib/blacklight/solr_response/group_response.rb
blacklight-5.13.1 lib/blacklight/solr_response/group_response.rb