module CanvasSync::JobBatches::Batch::Callback::CallbackWorkerCommon

def perform(definition, event, opts, bid, parent_bid)

def perform(definition, event, opts, bid, parent_bid)
  return unless VALID_CALLBACKS.include?(event)
  method = nil
  target = :instance
  clazz = definition
  if clazz.is_a?(String)
    if clazz.include?('#')
      clazz, method = clazz.split("#")
    elsif clazz.include?('.')
      clazz, method = clazz.split(".")
      target = :class
    end
  end
  method ||= "on_#{event}"
  status = Batch::Status.new(bid)
  if clazz && object = Object.const_get(clazz)
    target = target == :instance ? object.new : object
    if target.respond_to?(method, true)
      target.send(method, status, opts)
    else
      Batch.logger.warn("Invalid callback method #{definition} - #{target.to_s} does not respond to #{method}")
    end
  else
    Batch.logger.warn("Invalid callback method #{definition} - Class #{clazz} not found")
  end
end