class Blacklight::Solr::Response::GroupResponse

Attributes

group[R]
group_field[R]
key[R]
response[R]

Public Class Methods

new(key, group, response) click to toggle source
# File lib/blacklight/solr/response/group_response.rb, line 8
def initialize key, group, response
  @key = key
  @group = group
  @response = response
end

Public Instance Methods

empty?() click to toggle source

Relying on a fallback (method missing) to @response is problematic as it will not evaluate the correct ‘total` method.

# File lib/blacklight/solr/response/group_response.rb, line 39
def empty?
  total.zero?
end
entry_name(options) click to toggle source

Overridden from Blacklight::Solr::Response::PaginationMethods to support grouped key specific i18n keys. ‘key` is the field being grouped

# File lib/blacklight/solr/response/group_response.rb, line 46
def entry_name(options)
  I18n.t(
    "blacklight.entry_name.grouped.#{key}",
    default: :'blacklight.entry_name.grouped.default',
    count: options[:count]
  )
end
group_limit() click to toggle source
# File lib/blacklight/solr/response/group_response.rb, line 22
def group_limit
  params.fetch(:'group.limit', 1).to_s.to_i
end
groups() click to toggle source
# File lib/blacklight/solr/response/group_response.rb, line 16
def groups
  @groups ||= group["groups"].map do |g|
    Blacklight::Solr::Response::Group.new g[:groupValue], g, self
  end
end
method_missing(meth, *args, &block) click to toggle source
Calls superclass method
# File lib/blacklight/solr/response/group_response.rb, line 54
def method_missing meth, *args, &block
  if response.respond_to? meth
    response.send(meth, *args, &block)
  else
    super
  end
end
respond_to_missing?(meth, include_private = false) click to toggle source
Calls superclass method
# File lib/blacklight/solr/response/group_response.rb, line 62
def respond_to_missing? meth, include_private = false
  response.respond_to?(meth) || super
end
start() click to toggle source
# File lib/blacklight/solr/response/group_response.rb, line 32
def start
  params[:start].to_s.to_i
end
total() click to toggle source
# File lib/blacklight/solr/response/group_response.rb, line 26
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