From 12249263585271913373b5aed418c0ca22915c59 Mon Sep 17 00:00:00 2001 From: David Campbell Date: Thu, 5 Dec 2024 10:33:34 -0500 Subject: [PATCH] shared delegates module --- .../hyrax/work_show_presenter_override.rb | 6 +----- app/presenters/hyrax/data_set_presenter.rb | 6 +----- app/presenters/hyrax/shared_delegates.rb | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 app/presenters/hyrax/shared_delegates.rb diff --git a/app/overrides/presenters/hyrax/work_show_presenter_override.rb b/app/overrides/presenters/hyrax/work_show_presenter_override.rb index 33553c197..3a5b84d54 100644 --- a/app/overrides/presenters/hyrax/work_show_presenter_override.rb +++ b/app/overrides/presenters/hyrax/work_show_presenter_override.rb @@ -2,11 +2,7 @@ # [hyc-override] Overriding helper in order to add doi to citation # https://github.com/samvera/hyrax/blob/hyrax-v4.0.0/app/presenters/hyrax/work_show_presenter.rb Hyrax::WorkShowPresenter.class_eval do - # delegating just :doi seems to exclude the other fields, so pull all fields in from original file - delegate :title, :date_created, :date_issued, :description, :doi, :creator, :place_of_publication, - :creator_display, :contributor, :subject, :publisher, :language, :embargo_release_date, - :lease_expiration_date, :license, :source, :rights_statement, :thumbnail_id, :representative_id, - :rendering_ids, :member_of_collection_ids, :bibliographic_citation, :alternative_title, :member_ids, to: :solr_document + include Hyrax::SharedDelegates # [hyc-override] Add default scholarly? method # Indicates if the work is considered scholarly according to google scholar diff --git a/app/presenters/hyrax/data_set_presenter.rb b/app/presenters/hyrax/data_set_presenter.rb index 27deca540..0260259d4 100644 --- a/app/presenters/hyrax/data_set_presenter.rb +++ b/app/presenters/hyrax/data_set_presenter.rb @@ -3,11 +3,7 @@ # `rails generate hyrax:work DataSet` module Hyrax class DataSetPresenter < Hyrax::WorkShowPresenter - delegate :abstract, :admin_note, :contributor_display, :copyright_date, :creator_display, :date_issued, :dcmi_type, :deposit_record, :doi, - :extent, :funder, :kind_of_data, :last_modified_date, :language_label, - :license_label, :methodology, :note, :orcid_label, :other_affiliation_label, :project_director_display, :researcher_display, - :rights_holder, :rights_statement_label, :sponsor, to: :solr_document - + include Hyrax::SharedDelegates # See: WorkShowPresenter.scholarly? def scholarly? true diff --git a/app/presenters/hyrax/shared_delegates.rb b/app/presenters/hyrax/shared_delegates.rb new file mode 100644 index 000000000..9f128e605 --- /dev/null +++ b/app/presenters/hyrax/shared_delegates.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true +module Hyrax + module SharedDelegates + extend ActiveSupport::Concern + included do + delegate :abstract, :admin_note, :alternative_title, :bibliographic_citation, :contributor, :contributor_display, :copyright_date, + :creator, :creator_display, :date_created, :date_issued, :dcmi_type, :deposit_record, :description, :doi, :embargo_release_date, + :extent, :funder, :human_readable_type, :identifier, :itemtype, :kind_of_data, :language, :language_label, :last_modified_date, + :lease_expiration_date, :license, :license_label, :member_ids, :member_of_collection_ids, :methodology, :note, :orcid_label, + :other_affiliation_label, :place_of_publication, :project_director_display, :publisher, :related_url, :rendering_ids, :representative_id, :researcher_display, + :resource_type, :rights_holder, :rights_notes, :rights_statement, :rights_statement_label, :sponsor, :source, :subject, + :thumbnail_id, :title, to: :solr_document + end + end + end