Class: SidekiqSimpleDelay::SimpleDelayedWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
lib/sidekiq_simple_delay/delay_worker.rb

Overview

Worker that handles the simple_delayed functionality

Instance Method Summary collapse

Instance Method Details

#perform(args) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sidekiq_simple_delay/delay_worker.rb', line 10

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