Module: CanvasSync::JobBatches::ActiveJob::BatchAwareJob

Extended by:
ActiveSupport::Concern
Defined in:
lib/canvas_sync/job_batches/active_job.rb

Instance Method Summary collapse

Instance Method Details

#batchObject



41
42
43
# File 'lib/canvas_sync/job_batches/active_job.rb', line 41

def batch
  Thread.current[CURRENT_BATCH_THREAD_KEY]
end

#batch_contextObject



45
46
47
# File 'lib/canvas_sync/job_batches/active_job.rb', line 45

def batch_context
  batch&.context || {}
end

#bidObject



37
38
39
# File 'lib/canvas_sync/job_batches/active_job.rb', line 37

def bid
  @bid || Thread.current[CURRENT_BATCH_THREAD_KEY]&.bid
end

#deserialize(data) ⇒ Object



60
61
62
63
# File 'lib/canvas_sync/job_batches/active_job.rb', line 60

def deserialize(data)
  super
  @bid = data['batch_id']
end

#serializeObject



53
54
55
56
57
58
# File 'lib/canvas_sync/job_batches/active_job.rb', line 53

def serialize
  super.tap do |data|
    data['batch_id'] = @bid # This _must_ be @bid - not just bid
    data
  end
end

#valid_within_batch?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/canvas_sync/job_batches/active_job.rb', line 49

def valid_within_batch?
  batch.valid?
end