From 8066b7e16e580c139f6a0f37f4f2b6b4ad6eb626 Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Fri, 19 Jan 2024 14:06:19 -0500 Subject: [PATCH] Remove instance variable declaration This is not necessary and will keep an instance around in memory for longer than we need --- app/indexers/concerns/iiif_print/child_indexer.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/indexers/concerns/iiif_print/child_indexer.rb b/app/indexers/concerns/iiif_print/child_indexer.rb index 6944e17f..eeaf0ea1 100644 --- a/app/indexers/concerns/iiif_print/child_indexer.rb +++ b/app/indexers/concerns/iiif_print/child_indexer.rb @@ -17,25 +17,27 @@ def self.decorate_work_types! next unless work_type.iiif_print_config? if IiifPrint.use_valkyrie?(work_type) - decorate_valkyrie_resource(work_type) + indexer = decorate_valkyrie_resource(work_type) else - decorate_af_object(work_type) + indexer = decorate_af_object(work_type) end - @indexer.prepend(self).class_attribute(:iiif_print_lineage_service, default: IiifPrint::LineageService) unless @indexer.respond_to?(:iiif_print_lineage_service) + indexer.prepend(self).class_attribute(:iiif_print_lineage_service, default: IiifPrint::LineageService) unless indexer.respond_to?(:iiif_print_lineage_service) work_type::GeneratedResourceSchema.send(:include, IiifPrint::SetChildFlag) if work_type.const_defined?(:GeneratedResourceSchema) end end def self.decorate_valkyrie_resource(work_type) work_type.send(:include, Hyrax::Schema(:child_works_from_pdf_splitting)) unless work_type.included_modules.include?(Hyrax::Schema(:child_works_from_pdf_splitting)) - @indexer = "#{work_type.to_s}Indexer".constantize - @indexer.send(:include, Hyrax::Indexer(:child_works_from_pdf_splitting)) unless @indexer.included_modules.include?(Hyrax::Indexer(:child_works_from_pdf_splitting)) + # TODO: Use `Hyrax::ValkyrieIndexer.indexer_class_for` once changes are merged. + indexer = "#{work_type.to_s}Indexer".constantize + indexer.send(:include, Hyrax::Indexer(:child_works_from_pdf_splitting)) unless indexer.included_modules.include?(Hyrax::Indexer(:child_works_from_pdf_splitting)) + indexer end def self.decorate_af_object(work_type) work_type.send(:include, IiifPrint::SetChildFlag) unless work_type.included_modules.include?(IiifPrint::SetChildFlag) - @indexer = work_type.indexer + work_type.indexer end def to_solr