Class: LcpRuby::Events::AsyncHandlerJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/lcp_ruby/events/async_handler_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(handler_class_name, args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/lcp_ruby/events/async_handler_job.rb', line 6

def perform(handler_class_name, args)
  handler_class = handler_class_name.constantize
  record_class = args["record_class"].constantize
  record = record_class.find(args["record_id"])

  context = {
    record: record,
    changes: args["changes"] || {},
    event_name: args["event_name"]
  }

  handler_class.new(context).call
end