Skip to content

Commit

Permalink
Deprecate the @response instance variable in catalog#show
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Sep 15, 2016
1 parent 538a863 commit 5a30e94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/controllers/concerns/blacklight/catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def index
# get a single document from the index
# to add responses for formats other than html or json see _Blacklight::Document::Export_
def show
@response, @document = fetch params[:id]
deprecated_response, @document = fetch params[:id]
@response = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(deprecated_response, 'The @response instance variable is deprecated; use @document.response instead.')

respond_to do |format|
format.html { setup_next_and_previous_documents }
format.json { render json: { response: { document: @document } } }
Expand Down
18 changes: 15 additions & 3 deletions app/helpers/blacklight/catalog_helper_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true
module Blacklight::CatalogHelperBehavior
extend Deprecation
self.deprecation_horizon = 'blacklight 8.0'

include ConfigurationHelperBehavior
include ComponentHelperBehavior
include FacetsHelperBehavior
Expand Down Expand Up @@ -253,9 +256,18 @@ def default_view_type_group_icon_classes view
"glyphicon-#{view.to_s.parameterize} view-icon-#{view.to_s.parameterize}"
end

def current_bookmarks response = nil
response ||= @response
@current_bookmarks ||= current_or_guest_user.bookmarks_for_documents(response.documents).to_a
def current_bookmarks documents_or_response = nil
documents = if documents_or_response.respond_to? :documents
Deprecation.warn(Blacklight::CatalogHelperBehavior, "Passing a response to #current_bookmarks is deprecated; pass response.documents instead")
documents_or_response.documents
else
documents_or_response
end

documents ||= [@document] if @document.present?
documents ||= @response.documents

@current_bookmarks ||= current_or_guest_user.bookmarks_for_documents(documents).to_a
end

##
Expand Down

0 comments on commit 5a30e94

Please sign in to comment.