diff --git a/app/forms/hyrax/forms/collection_form.rb b/app/forms/hyrax/forms/collection_form.rb index 7b4235b51b..189fe36c11 100644 --- a/app/forms/hyrax/forms/collection_form.rb +++ b/app/forms/hyrax/forms/collection_form.rb @@ -53,7 +53,9 @@ def all_files end def member_presenters - PresenterFactory.build_presenters(model.member_ids, WorkShowPresenter, nil) + PresenterFactory.build_for(ids: model.member_ids, + presenter_class: WorkShowPresenter, + presenter_args: [nil]) end end end diff --git a/app/forms/hyrax/forms/work_form.rb b/app/forms/hyrax/forms/work_form.rb index f0b7295f94..e5652c08c4 100644 --- a/app/forms/hyrax/forms/work_form.rb +++ b/app/forms/hyrax/forms/work_form.rb @@ -126,7 +126,9 @@ def self.workflow_for(admin_set_id:) # @return [Array] presenters for the file sets in order of the ids def file_presenters @file_sets ||= - Hyrax::PresenterFactory.build_presenters(model.member_ids, FileSetPresenter, current_ability) + Hyrax::PresenterFactory.build_for(ids: model.member_ids, + presenter_class: FileSetPresenter, + presenter_args: current_ability) end end end diff --git a/app/models/featured_work_list.rb b/app/models/featured_work_list.rb index 6cbbf64296..93c796943e 100644 --- a/app/models/featured_work_list.rb +++ b/app/models/featured_work_list.rb @@ -36,9 +36,9 @@ def ids def work_presenters ability = nil - Hyrax::PresenterFactory.build_presenters(ids, - Hyrax::WorkShowPresenter, - ability) + Hyrax::PresenterFactory.build_for(ids: ids, + presenter_class: Hyrax::WorkShowPresenter, + presenter_args: ability) end def work_with_id(id) diff --git a/app/presenters/hyrax/file_set_presenter.rb b/app/presenters/hyrax/file_set_presenter.rb index 61ef8534f7..290ce0ea4e 100644 --- a/app/presenters/hyrax/file_set_presenter.rb +++ b/app/presenters/hyrax/file_set_presenter.rb @@ -84,9 +84,9 @@ def parent ids = ActiveFedora::SolrService.query("{!field f=member_ids_ssim}#{id}", fl: ActiveFedora.id_field) .map { |x| x.fetch(ActiveFedora.id_field) } - @parent_presenter ||= Hyrax::PresenterFactory.build_presenters(ids, - WorkShowPresenter, - current_ability).first + @parent_presenter ||= Hyrax::PresenterFactory.build_for(ids: ids, + presenter_class: WorkShowPresenter, + presenter_args: current_ability).first end def fixity_check_service diff --git a/app/presenters/hyrax/member_presenter_factory.rb b/app/presenters/hyrax/member_presenter_factory.rb index fc4d3a01cc..916582b378 100644 --- a/app/presenters/hyrax/member_presenter_factory.rb +++ b/app/presenters/hyrax/member_presenter_factory.rb @@ -21,7 +21,9 @@ def initialize(work, ability, request = nil) # @param [Class] presenter_class the type of presenter to build # @return [Array] presenters for the ordered_members (not filtered by class) def member_presenters(ids = ordered_ids, presenter_class = composite_presenter_class) - PresenterFactory.build_presenters(ids, presenter_class, *presenter_factory_arguments) + PresenterFactory.build_for(ids: ids, + presenter_class: presenter_class, + presenter_args: presenter_factory_arguments) end # @return [Array] presenters for the orderd_members that are FileSets diff --git a/app/presenters/hyrax/presenter_factory.rb b/app/presenters/hyrax/presenter_factory.rb index a13a56a85b..848acf18a3 100644 --- a/app/presenters/hyrax/presenter_factory.rb +++ b/app/presenters/hyrax/presenter_factory.rb @@ -21,10 +21,7 @@ def build_for(ids:, presenter_class:, presenter_args: []) # @param [Array] args any other arguments to pass to the presenters # @return [Array] presenters for the documents in order of the ids def build_presenters(ids, klass, *args) - Deprecation.warn(to_s, - Deprecation.deprecated_method_warning(to_s, - :build_presenters, - "use .build_for instead")) + Deprecation.warn(self, "build_presenters is deprecated and will be removed from Hyrax 3.0 (use .build_for instead)") build_for(ids: ids, presenter_class: klass, presenter_args: args) end end diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index 2a44c0464c..7b8e20031c 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -64,9 +64,9 @@ def representative_presenter # Get presenters for the collections this work is a member of via the member_of_collections association. # @return [Array] presenters def member_of_collection_presenters - PresenterFactory.build_presenters(member_of_collection_ids, - collection_presenter_class, - *presenter_factory_arguments) + PresenterFactory.build_for(ids: member_of_collection_ids, + presenter_class: collection_presenter_class, + presenter_args: presenter_factory_arguments) end def date_modified diff --git a/spec/presenters/hyrax/member_presenter_factory_spec.rb b/spec/presenters/hyrax/member_presenter_factory_spec.rb index 8d772cc454..ddb1438aa9 100644 --- a/spec/presenters/hyrax/member_presenter_factory_spec.rb +++ b/spec/presenters/hyrax/member_presenter_factory_spec.rb @@ -16,8 +16,10 @@ end it "uses the set class" do - expect(Hyrax::PresenterFactory).to receive(:build_presenters) - .with(['12', '33'], presenter_class, ability, request) + expect(Hyrax::PresenterFactory).to receive(:build_for) + .with(ids: ['12', '33'], + presenter_class: presenter_class, + presenter_args: [ability, request]) factory.file_set_presenters end end diff --git a/spec/presenters/hyrax/work_show_presenter_spec.rb b/spec/presenters/hyrax/work_show_presenter_spec.rb index ce4e997a84..92ff154dba 100644 --- a/spec/presenters/hyrax/work_show_presenter_spec.rb +++ b/spec/presenters/hyrax/work_show_presenter_spec.rb @@ -175,8 +175,11 @@ let(:obj) { create(:work_with_representative_file) } let(:attributes) { obj.to_solr } it "has a representative" do - expect(Hyrax::PresenterFactory).to receive(:build_presenters) - .with([obj.members[0].id], Hyrax::CompositePresenterFactory, ability, request).and_return ["abc"] + expect(Hyrax::PresenterFactory).to receive(:build_for) + .with(ids: [obj.members[0].id], + presenter_class: Hyrax::CompositePresenterFactory, + presenter_args: [ability, request]) + .and_return ["abc"] expect(presenter.representative_presenter).to eq("abc") end end