Sha256: 5927c51c111f4ab3d71b90fb096c60fba9745ee6e89f8d6f03f40de416041545

Contents?: true

Size: 1.01 KB

Versions: 55

Compression:

Stored size: 1.01 KB

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
      Deprecation.silence(Blacklight::Facet) do
        facets_from_request(facet_field_names, @response).select { |display_facet| display_facet.items.present? }
      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

55 entries across 55 versions & 2 rubygems

Version Path
blacklight-7.40.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.39.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.38.0 app/presenters/blacklight/json_presenter.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/presenters/blacklight/json_presenter.rb
blacklight-7.37.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.36.2 app/presenters/blacklight/json_presenter.rb
blacklight-7.36.1 app/presenters/blacklight/json_presenter.rb
blacklight-7.36.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.35.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.34.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.33.1 app/presenters/blacklight/json_presenter.rb
blacklight-7.33.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.32.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.31.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.30.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.29.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.28.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.27.1 app/presenters/blacklight/json_presenter.rb
blacklight-7.27.0 app/presenters/blacklight/json_presenter.rb
blacklight-7.26.1 app/presenters/blacklight/json_presenter.rb