Sha256: 03fb8c1dc1131a5a65624fd2ff82b2cb24fcbd514f7351b593cdc2164df82185

Contents?: true

Size: 655 Bytes

Versions: 7

Compression:

Stored size: 655 Bytes

Contents

module Spotlight
  ##
  # Reindex the given resources or exhibits
  class ReindexJob < ActiveJob::Base
    queue_as :default

    before_enqueue do |job|
      resource_list(job.arguments.first).each(&:waiting!)
    end

    def perform(exhibit_or_resources)
      resource_list(exhibit_or_resources).each(&:reindex)
    end

    private

    def resource_list(exhibit_or_resources)
      case
      when exhibit_or_resources.is_a?(Spotlight::Exhibit)
        exhibit_or_resources.resources.find_each
      when exhibit_or_resources.is_a?(Enumerable)
        exhibit_or_resources
      else
        Array(exhibit_or_resources)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
blacklight-spotlight-0.17.1 app/jobs/spotlight/reindex_job.rb
blacklight-spotlight-0.17.0 app/jobs/spotlight/reindex_job.rb
blacklight-spotlight-0.16.0 app/jobs/spotlight/reindex_job.rb
blacklight-spotlight-0.15.0 app/jobs/spotlight/reindex_job.rb
blacklight-spotlight-0.14.2 app/jobs/spotlight/reindex_job.rb
blacklight-spotlight-0.14.1 app/jobs/spotlight/reindex_job.rb
blacklight-spotlight-0.14.0 app/jobs/spotlight/reindex_job.rb