Class: RobotLab::RailsIntegration::Job
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- RobotLab::RailsIntegration::Job
- Defined in:
- lib/robot_lab/rails_integration/job.rb
Overview
Base class for RobotLab background jobs.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.robot_class(klass = nil) ⇒ Object
14 15 16 |
# File 'lib/robot_lab/rails_integration/job.rb', line 14 def self.robot_class(klass = nil) klass ? @robot_class = klass : @robot_class end |
Instance Method Details
#perform(message:, robot_class: nil, thread_id: nil, **context) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/robot_lab/rails_integration/job.rb', line 21 def perform(message:, robot_class: nil, thread_id: nil, **context) klass = resolve_robot_class(robot_class) thread = setup_thread(thread_id, ) robot = build_robot(klass, thread_id) result = robot.run(, **context) if thread persist_result(thread, result) broadcast_completion(thread_id) end result rescue StandardError => e broadcast_error(thread_id, e) if thread_id raise end |