Skip to content

Commit

Permalink
shared delegates module
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcam-src committed Dec 5, 2024
1 parent b49c03e commit 1224926
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions app/presenters/hyrax/data_set_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions app/presenters/hyrax/shared_delegates.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1224926

Please sign in to comment.