Skip to content

Commit

Permalink
🐛 Use configured class instead of hard-coded (#6717)
Browse files Browse the repository at this point in the history
The baseline configuration for the `Hyrax::PcdmMemberPresenterFactory`
allows for us to specify the `file_presenter_class` and the
`work_presenter_class`.  However, in the case of `presenter_for` we were
not leveraging that configurability.

This commit rectifies that behavior.

Tagging along with this commit is a minor performance improvement.
Namely, check a simple boolean before we begin checking elements that
might require additional queries and/or loading additional objects.
  • Loading branch information
jeremyf authored Mar 11, 2024
1 parent 2b3854f commit bfa53c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/presenters/hyrax/pcdm_member_presenter_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ def work_presenters
def presenter_for(document:, ability:)
case document['has_model_ssim'].first
when *Hyrax::ModelRegistry.file_set_rdf_representations
Hyrax::FileSetPresenter.new(document, ability)
file_presenter_class.new(document, ability)
else
Hyrax::WorkShowPresenter.new(document, ability)
work_presenter_class.new(document, ability)
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/presenters/hyrax/work_show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def download_url

# @return [Boolean] render a IIIF viewer
def iiif_viewer?
representative_id.present? &&
Hyrax.config.iiif_image_server? &&
representative_id.present? &&
representative_presenter.present? &&
representative_presenter.image? &&
Hyrax.config.iiif_image_server? &&
members_include_viewable_image?
end

Expand Down

0 comments on commit bfa53c4

Please sign in to comment.