Class: Blacklight::JsonPresenter
- Inherits:
-
Object
- Object
- Blacklight::JsonPresenter
- Defined in:
- app/presenters/blacklight/json_presenter.rb
Instance Attribute Summary collapse
-
#blacklight_config ⇒ Object
readonly
Returns the value of attribute blacklight_config.
Instance Method Summary collapse
- #documents ⇒ Object
-
#initialize(response, blacklight_config) ⇒ JsonPresenter
constructor
A new instance of JsonPresenter.
-
#pagination_info ⇒ Object
extract the pagination info from the response object.
- #search_facets ⇒ Array<Blacklight::Solr::Response::Facets::FacetField>
Constructor Details
#initialize(response, blacklight_config) ⇒ JsonPresenter
Returns a new instance of JsonPresenter.
7 8 9 10 |
# File 'app/presenters/blacklight/json_presenter.rb', line 7 def initialize(response, blacklight_config) @response = response @blacklight_config = blacklight_config end |
Instance Attribute Details
#blacklight_config ⇒ Object (readonly)
Returns the value of attribute blacklight_config.
12 13 14 |
# File 'app/presenters/blacklight/json_presenter.rb', line 12 def blacklight_config @blacklight_config end |
Instance Method Details
#documents ⇒ Object
16 17 18 |
# File 'app/presenters/blacklight/json_presenter.rb', line 16 def documents @response.documents end |
#pagination_info ⇒ Object
extract the pagination info from the response object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/presenters/blacklight/json_presenter.rb', line 29 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_facets ⇒ Array<Blacklight::Solr::Response::Facets::FacetField>
21 22 23 24 25 26 |
# File 'app/presenters/blacklight/json_presenter.rb', line 21 def search_facets facet_field_names .map { |field| @response.aggregations[facet_configuration_for_field(field).field] } .compact .select { |display_facet| display_facet.items.present? } end |