Sha256: 3b4247cc0bd607c7cd19ad0d4c4f49442b43e50970b06a442d7793b01404026d
Contents?: true
Size: 1.5 KB
Versions: 21
Compression:
Stored size: 1.5 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 ## # Overridden from Blacklight::Solr::Response::PaginationMethods to support # grouped key specific i18n keys. `key` is the field being grouped def entry_name(options) I18n.t( "blacklight.entry_name.grouped.#{key}", default: :'blacklight.entry_name.grouped.default', count: options[:count] ) 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 & 2 rubygems