Class: Ocpp::Rails::AuthorizationAsyncHookJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/ocpp/rails/authorization_async_hook_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(authorization_id, hook_class_name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/jobs/ocpp/rails/authorization_async_hook_job.rb', line 8

def perform(authorization_id, hook_class_name)
  authorization = Ocpp::Rails::Authorization.find_by(id: authorization_id)

  unless authorization
    ::Rails.logger.warn("Authorization #{authorization_id} not found, may have been cleaned up")
    return
  end

  hook_class = hook_class_name.constantize
  hook = hook_class.new
  hook.call(authorization)
rescue => error
  ::Rails.logger.error("AuthorizationAsyncHook #{hook_class_name} failed for Authorization #{authorization_id}: #{error.message}")
  raise
end