class Sidekiq::Sequence::Base

Attributes

steps[R]

Public Class Methods

new(data = {}) click to toggle source
# File lib/sidekiq/sequence/base.rb, line 24
def initialize(data = {})
  record = Record.create(data: data)

  # Start first job in the sequence.
  self.class.steps.first.constantize.perform_async record.id
end
perform_step(index, id) click to toggle source
# File lib/sidekiq/sequence/base.rb, line 15
def self.perform_step(index, id)
  if index >= steps.size
    # No more steps in the sequence, so delete the record.
    Record.destroy id
  else
    steps[index].constantize.perform_async id
  end
end
step(worker_class) click to toggle source
# File lib/sidekiq/sequence/base.rb, line 9
def step(worker_class)
  @steps = [] if steps.nil?
  @steps << worker_class.name
end