Class: Sidekiq::Batch::Callback::Worker

Inherits:
Object
  • Object
show all
Includes:
Worker
Defined in:
lib/sidekiq/batch/callback.rb

Instance Method Summary collapse

Instance Method Details

#perform(clazz, event, opts, bid, parent_bid) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sidekiq/batch/callback.rb', line 7

def perform(clazz, event, opts, bid, parent_bid)
  return unless %w(success complete).include?(event)
  clazz, method = clazz.split("#") if (clazz && clazz.class == String && clazz.include?("#"))
  method = "on_#{event}" if method.nil?
  status = Sidekiq::Batch::Status.new(bid)

  if clazz && object = Object.const_get(clazz)
    instance = object.new
    instance.send(method, status, opts) if instance.respond_to?(method)
  end
end