Module: ChainedJob::Middleware
- Defined in:
- lib/chained_job/middleware.rb
Class Method Summary collapse
Instance Method Summary collapse
- #arguments_array(args) ⇒ Object
- #array_of_job_arguments ⇒ Object
- #job_arguments_key ⇒ Object
- #parallelism ⇒ Object
- #perform(args = {}, worker_id = nil, tag = nil) ⇒ Object
Class Method Details
.included(base) ⇒ Object
8 9 10 |
# File 'lib/chained_job/middleware.rb', line 8 def self.included(base) base.queue_as ChainedJob.config.queue if ChainedJob.config.queue end |
Instance Method Details
#arguments_array(args) ⇒ Object
24 25 26 27 |
# File 'lib/chained_job/middleware.rb', line 24 def arguments_array(args) = { job_class: self.class, args: args } ChainedJob.config.around_array_of_job_arguments.call() { array_of_job_arguments } end |
#array_of_job_arguments ⇒ Object
29 30 31 |
# File 'lib/chained_job/middleware.rb', line 29 def array_of_job_arguments raise NoMethodError, 'undefined method array_of_job_arguments' end |
#job_arguments_key ⇒ Object
37 38 39 |
# File 'lib/chained_job/middleware.rb', line 37 def job_arguments_key self.class end |
#parallelism ⇒ Object
33 34 35 |
# File 'lib/chained_job/middleware.rb', line 33 def parallelism raise NoMethodError, 'undefined method parallelism' end |
#perform(args = {}, worker_id = nil, tag = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/chained_job/middleware.rb', line 12 def perform(args = {}, worker_id = nil, tag = nil) unless Hash === args # backward compatibility args, worker_id, tag = {}, args, worker_id end if worker_id ChainedJob::Process.run(args, self, job_arguments_key, worker_id, tag) else ChainedJob::StartChains.run(args, self.class, job_arguments_key, arguments_array(args), parallelism) end end |