Sha256: ce1c478a2bc0c322d8171a4ab4d139d17bd7b810bf50e9928fc5555d9a9bbd85

Contents?: true

Size: 978 Bytes

Versions: 13

Compression:

Stored size: 978 Bytes

Contents

# frozen_string_literal: true
module Blacklight
  class JsonPresenter
    include Blacklight::Facet

    # @param [Solr::Response] response raw solr response.
    # @param [Configuration] blacklight_config the configuration
    def initialize(response, blacklight_config)
      @response = response
      @blacklight_config = blacklight_config
    end

    attr_reader :blacklight_config

    def documents
      @response.documents
    end

    # @return [Array<Blacklight::Solr::Response::Facets::FacetField>]
    def search_facets
      facets_from_request(facet_field_names, @response).select { |display_facet| display_facet.items.present? }
    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

13 entries across 13 versions & 1 rubygems

Version Path
blacklight-7.11.1 app/presenters/blacklight/json_presenter.rb
blacklight-7.10.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.9.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.8.1 app/presenters/blacklight/json_presenter.rb
blacklight-7.8.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.7.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.6.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.5.1 app/presenters/blacklight/json_presenter.rb
blacklight-7.5.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.4.2 app/presenters/blacklight/json_presenter.rb
blacklight-7.4.1 app/presenters/blacklight/json_presenter.rb
blacklight-7.4.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.3.0 app/presenters/blacklight/json_presenter.rb