Sha256: 90a51c7a9eaa52cb512630d16bb7b52db43e252cc7f209ff294f45470a1ca071

Contents?: true

Size: 1.07 KB

Versions: 11

Compression:

Stored size: 1.07 KB

Contents

require 'delayed_job'

module DelayedPaperclip
  module Jobs
    class DelayedJob < Struct.new(:instance_klass, :instance_id, :attachment_name)

      if defined?(::Delayed::DeserializationError) # this is available in newer versions of DelayedJob. Using the newee Job api thus.

        def self.enqueue_delayed_paperclip(instance_klass, instance_id, attachment_name)
          ::Delayed::Job.enqueue(
            :payload_object => new(instance_klass, instance_id, attachment_name),
            :priority => instance_klass.constantize.attachment_definitions[attachment_name][:delayed][:priority].to_i
          )
        end

      else

        def self.enqueue_delayed_paperclip(instance_klass, instance_id, attachment_name)
          ::Delayed::Job.enqueue(
            new(instance_klass, instance_id, attachment_name),
            instance_klass.constantize.attachment_definitions[attachment_name][:delayed][:priority].to_i
          )
        end

      end

      def perform
        DelayedPaperclip.process_job(instance_klass, instance_id, attachment_name)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
delayed_paperclip-2.6.0.0 lib/delayed_paperclip/jobs/delayed_job.rb
delayed_paperclip-2.5.1.0 lib/delayed_paperclip/jobs/delayed_job.rb
delayed_paperclip-2.5.0.1 lib/delayed_paperclip/jobs/delayed_job.rb
delayed_paperclip-2.4.5.2 lib/delayed_paperclip/jobs/delayed_job.rb
delayed_paperclip-2.4.5.1 lib/delayed_paperclip/jobs/delayed_job.rb
delayed_paperclip-2.4.5.0 lib/delayed_paperclip/jobs/delayed_job.rb
delayed_paperclip-2.4.4.0 lib/delayed_paperclip/jobs/delayed_job.rb
delayed_paperclip-2.4.3.0 lib/delayed_paperclip/jobs/delayed_job.rb
delayed_paperclip-2.4.2.0 lib/delayed_paperclip/jobs/delayed_job.rb
delayed_paperclip-2.4.1.0 lib/delayed_paperclip/jobs/delayed_job.rb
delayed_paperclip-2.4.0.0 lib/delayed_paperclip/jobs/delayed_job.rb