Sha256: 9536c91520749a8e4d6cb42f3505098d30404c57fd8bb09fa51bf0162b016cef
Contents?: true
Size: 1.17 KB
Versions: 21
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true class Blacklight::Solr::Response::GroupResponse include Blacklight::Solr::Response::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::Solr::Response::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 ## # Relying on a fallback (method missing) to @response is problematic as it # will not evaluate the correct `total` method. def empty? total.zero? end def method_missing meth, *args, &block if response.respond_to? meth response.send(meth, *args, &block) else super end end def respond_to_missing? meth, include_private = false response.respond_to?(meth) || super end end
Version data entries
21 entries across 21 versions & 1 rubygems