Sha256: b6e34e35f337c6b46b501c2ad381a1d4537281e1a2ab99b44dd7994aaa0d07c2

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Spotlight::Resources
  # Base Resource harvester for objects in DOR
  class DorHarvester < Spotlight::Resource
    self.document_builder_class = Spotlight::Resources::DorSolrDocumentBuilder

    store :data, accessors: [:druid_list]

    class << self
      def instance(current_exhibit)
        find_or_initialize_by exhibit: current_exhibit
      end
    end

    def resources
      @resources ||= druids.map do |d|
        Spotlight::Dor::Resources.indexer.resource d
      end
    end

    def druids
      @druids ||= druid_list.split(/\s+/).reject(&:blank?)
    end

    ##
    # Enumerate the resource, and any collection members, that should be indexed
    # into this exhibit
    #
    # @return [Enumerator] an enumerator of resources to index
    def indexable_resources
      return to_enum(:indexable_resources) { resources.size + resources.sum { |r| r.items.size } } unless block_given?

      resources.each do |resource|
        yield resource

        resource.items.each do |r|
          yield r
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spotlight-dor-resources-2.0.0 app/models/spotlight/resources/dor_harvester.rb