Skip to content

Commit

Permalink
Remove instance variable declaration
Browse files Browse the repository at this point in the history
This is not necessary and will keep an instance around
in memory for longer than we need
  • Loading branch information
jeremyf committed Jan 19, 2024
1 parent 5ab4c2a commit 8066b7e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/indexers/concerns/iiif_print/child_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8066b7e

Please sign in to comment.