Sha256: 322d94ff50886b5a828b15613a42f41e437a58b34fc2ee8ee617d384bac21e32

Contents?: true

Size: 751 Bytes

Versions: 2

Compression:

Stored size: 751 Bytes

Contents

# frozen_string_literal: true

module Emittance
  module Resque
    class Dispatcher
      ##
      # Use this to build a job class from a callback block/proc/lambda.
      #
      class JobKlass
        # The name of the method used by the background job library to perform the job.
        PERFORM_METHOD_NAME = :perform

        def initialize(callback, queue: :default)
          @callback = callback
          @queue = queue
        end

        def generate
          klass = Class.new(Emittance::Resque::Job)
          klass.send(:define_method, PERFORM_METHOD_NAME, callback)
          klass.instance_variable_set '@queue', queue

          klass
        end

        private

        attr_reader :callback, :queue
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
emittance-resque-0.1.1 lib/emittance/resque/dispatcher/job_klass.rb
emittance-resque-0.1.0 lib/emittance/resque/dispatcher/job_klass.rb