Skip to content

Commit

Permalink
Avoid deprecation notice on ActiveSupport::Deprecation::DeprecatedObj…
Browse files Browse the repository at this point in the history
…ectProxy by passing specific deprecation object with correct gem and version

DEPRECATION WARNING: DeprecatedObjectProxy without a deprecator is deprecated
  • Loading branch information
jrochkind committed Nov 8, 2023
1 parent 1975cbc commit af8b821
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/controllers/concerns/blacklight/bookmarks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ def index
@bookmarks = token_or_current_or_guest_user.bookmarks
bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }
@response, deprecated_document_list = search_service.fetch(bookmark_ids)
@document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(deprecated_document_list, "The @document_list instance variable is now deprecated and will be removed in Blacklight 8.0")
@document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
deprecated_document_list,
"The @document_list instance variable is now deprecated",
ActiveSupport::Deprecation.new("8.0", "blacklight")
)

respond_to do |format|
format.html {}
Expand Down
12 changes: 10 additions & 2 deletions app/controllers/concerns/blacklight/catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ module Blacklight::Catalog
def index
(@response, deprecated_document_list) = search_service.search_results

@document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(deprecated_document_list, 'The @document_list instance variable is deprecated; use @response.documents instead.')
@document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
deprecated_document_list,
'The @document_list instance variable is deprecated; use @response.documents instead.',
ActiveSupport::Deprecation.new("8.0", "blacklight")
)

respond_to do |format|
format.html { store_preferred_view }
Expand All @@ -53,7 +57,11 @@ def index
# to add responses for formats other than html or json see _Blacklight::Document::Export_
def show
deprecated_response, @document = search_service.fetch(params[:id])
@response = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(deprecated_response, 'The @response instance variable is deprecated; use @document.response instead.')
@response = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(
deprecated_response,
'The @response instance variable is deprecated; use @document.response instead.',
ActiveSupport::Deprecation.new("8.0", "blacklight")
)

respond_to do |format|
format.html { @search_context = setup_next_and_previous_documents }
Expand Down

0 comments on commit af8b821

Please sign in to comment.