Class: Blacklight::JsonPresenter

Inherits:
Object
  • Object
show all
Includes:
Facet
Defined in:
app/presenters/blacklight/json_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Facet

#facet_by_field_name, #facet_paginator, #facets_from_request

Constructor Details

#initialize(response, blacklight_config) ⇒ JsonPresenter

Returns a new instance of JsonPresenter.

Parameters:



8
9
10
11
# File 'app/presenters/blacklight/json_presenter.rb', line 8

def initialize(response, blacklight_config)
  @response = response
  @blacklight_config = blacklight_config
end

Instance Attribute Details

#blacklight_configObject (readonly)

Returns the value of attribute blacklight_config.



13
14
15
# File 'app/presenters/blacklight/json_presenter.rb', line 13

def blacklight_config
  @blacklight_config
end

Instance Method Details

#pagination_infoObject

extract the pagination info from the response object



25
26
27
28
29
30
31
32
33
34
35
# File 'app/presenters/blacklight/json_presenter.rb', line 25

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

#search_facetsArray<Blacklight::Solr::Response::Facets::FacetField>



18
19
20
21
22
# File 'app/presenters/blacklight/json_presenter.rb', line 18

def search_facets
  Deprecation.silence(Blacklight::Facet) do
    facets_from_request(facet_field_names, @response).select { |display_facet| display_facet.items.present? }
  end
end