Sha256: 75167ad329a53dea637d749cecad265b83ed8d97b1c75b1e0446d3db0e92d968

Contents?: true

Size: 719 Bytes

Versions: 2

Compression:

Stored size: 719 Bytes

Contents

# frozen_string_literal: true

require 'sidekiq'

module SidekiqSimpleDelay
  # Worker that handles the simple_delayed functionality
  class SimpleDelayedWorker
    include Sidekiq::Worker

    def perform(args)
      target_klass = Object.const_get(args.fetch('target_klass'))

      target =
        if args.key?('init_args')
          if target_klass.respond_to?(:simple_delay_initialize)
            target_klass.simple_delay_initialize(*args['init_args'])
          else
            target_klass.new(*args['init_args'])
          end
        else
          target_klass
        end

      method_name = args['m']
      method_args = args['args']

      target.__send__(method_name, *method_args)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq_simple_delay-0.2.1 lib/sidekiq_simple_delay/delay_worker.rb
sidekiq_simple_delay-0.2.0 lib/sidekiq_simple_delay/delay_worker.rb