Class: Cosmo::Batch::Callback

Inherits:
Object
  • Object
show all
Includes:
Job
Defined in:
lib/cosmo/batch/callback.rb,
sig/cosmo/batch/callback.rbs

Overview

The actual job that gets enqueued when a batch finishes. It looks up the plain Ruby class you passed to Batch#on and calls on_success or on_complete on it.

Instance Attribute Summary

Attributes included from Job

#attempt, #batch_id, #enqueued_at, #jid, #scheduled_by

Instance Method Summary collapse

Methods included from Job

included, #logger

Instance Method Details

#perform(class_name, event, status, opts) ⇒ void

This method returns an undefined value.

Parameters:

  • class_name (::String)
  • event (Symbol)
  • status (Hash[Symbol, untyped])
  • opts (Hash[Symbol, untyped])


11
12
13
14
# File 'lib/cosmo/batch/callback.rb', line 11

def perform(class_name, event, status, opts)
  klass = Utils::String.safe_constantize(class_name)
  klass&.new&.public_send("on_#{event}", status, opts)
end