Module: ChainedJob::Middleware

Defined in:
lib/chained_job/middleware.rb

Class Method Summary collapse

Instance Method Summary collapse

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_arrayObject



20
21
22
23
# File 'lib/chained_job/middleware.rb', line 20

def arguments_array
  options = { job_class: self.class }
  ChainedJob.config.around_array_of_job_arguments.call(options) { array_of_job_arguments }
end

#array_of_job_argumentsObject

Raises:

  • (NoMethodError)


25
26
27
# File 'lib/chained_job/middleware.rb', line 25

def array_of_job_arguments
  raise NoMethodError, 'undefined method array_of_job_arguments'
end

#parallelismObject

Raises:

  • (NoMethodError)


29
30
31
# File 'lib/chained_job/middleware.rb', line 29

def parallelism
  raise NoMethodError, 'undefined method parallelism'
end

#perform(worker_id = nil, tag = nil) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/chained_job/middleware.rb', line 12

def perform(worker_id = nil, tag = nil)
  if worker_id
    ChainedJob::Process.run(self, worker_id, tag)
  else
    ChainedJob::StartChains.run(self.class, arguments_array, parallelism)
  end
end