Sha256: 5250eba227ff7d4c37b2d503bb2350326332267d81b03e61541217cace0c7ba5

Contents?: true

Size: 745 Bytes

Versions: 2

Compression:

Stored size: 745 Bytes

Contents

# frozen_string_literal: true

module Paperweight
  # Queues post processing.
  class PostProcessJob < ActiveJob::Base
    queue_as :default

    discard_on ActiveJob::DeserializationError

    rescue_from Download::Error do |error|
      raise error if executions >= Paperweight.config.download_attempts

      retry_job(wait: (executions**4) + 2)
    end

    def perform(model, name)
      name = AttachmentName.new(name)
      image_url = model.public_send(name.processing)

      return unless image_url

      model.update!(
        name.name => Download.download(image_url),
        name.processing => nil
      )

      return unless model.respond_to?(name.after_download)

      model.public_send(name.after_download)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
paperweight-1.2.1 lib/paperweight/post_process_job.rb
paperweight-1.2.0 lib/paperweight/post_process_job.rb