Module: Conductor::Worker::Annotatable
- Defined in:
- lib/conductor/worker/worker.rb
Overview
Module for method annotation style workers Extend this in your module to use worker_task on methods
Instance Method Summary collapse
-
#singleton_method_added(method_name) ⇒ Object
Hook called when a method is added.
-
#worker_task(task_definition_name, **options) ⇒ Object
Mark the next defined method as a worker.
Instance Method Details
#singleton_method_added(method_name) ⇒ Object
Hook called when a method is added
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/conductor/worker/worker.rb', line 329 def singleton_method_added(method_name) super return unless @pending_worker_task pending = @pending_worker_task @pending_worker_task = nil # Get the method and register it method_obj = method(method_name) WorkerRegistry.register( pending[:task_definition_name], method_obj, pending[:options] ) end |
#worker_task(task_definition_name, **options) ⇒ Object
Mark the next defined method as a worker
321 322 323 324 325 326 |
# File 'lib/conductor/worker/worker.rb', line 321 def worker_task(task_definition_name, **) @pending_worker_task = { task_definition_name: task_definition_name, options: } end |