class Lato::ApplicationJob

def manage_operation

def manage_operation
  @operation = Lato::Operation.find(arguments.first[:_operation_id]) if arguments.first && arguments.first.is_a?(Hash) && !arguments.first[:_operation_id].blank?
  @operation&.running
  begin
    yield
    @operation&.completed
  rescue StandardError => e
    return @operation.failed(e.message) if @operation
    raise e
  end
end