Sha256: e316df6b31a9fb198af344cf19aeb0cf6049ccdae3347a5a27fedca0c7727825

Contents?: true

Size: 642 Bytes

Versions: 1

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true

module AcidicJob
  # NOTE: it is essential that this be a bare module and not an ActiveSupport::Concern
  # WHY?
  module PerformWrapper
    def perform(*args, **kwargs)
      @arguments = args

      # we don't want to run the `perform` callbacks twice, since ActiveJob already handles that for us
      if defined?(ActiveJob) && self.class < ActiveJob::Base
        super(*args, **kwargs)
      elsif defined?(Sidekiq) && self.class.include?(Sidekiq::Worker)
        run_callbacks :perform do
          super(*args, **kwargs)
        end
      else
        raise UnknownJobAdapter
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acidic_job-1.0.0.beta.1 lib/acidic_job/perform_wrapper.rb