Sha256: 90a61303b996dda185526fb56b79e814b700c91d8b3e7df5f6777874084077ec
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module Blacklight class JsonPresenter include Blacklight::Facet # @param [Solr::Response] response raw solr response. # @param [Array] facets list of facets def initialize(response, facets, blacklight_config) @response = response @facets = facets @blacklight_config = blacklight_config end attr_reader :blacklight_config def documents @response.documents end def search_facets_as_json @facets.as_json.each do |f| f.stringify_keys! f.delete "options" f["label"] = facet_configuration_for_field(f["name"]).label f["items"] = f["items"].as_json.each do |i| i['label'] ||= i['value'] end end end # extract the pagination info from the response object def pagination_info h = {} [:current_page, :next_page, :prev_page, :total_pages, :limit_value, :offset_value, :total_count, :first_page?, :last_page?].each do |k| h[k] = @response.send(k) end h end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
blacklight-7.0.0.rc1 | app/presenters/blacklight/json_presenter.rb |