Module: Joblin::Batching::Compat::ActiveJob::BatchAwareJob
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/joblin/batching/compat/active_job.rb
Instance Method Summary collapse
- #batch ⇒ Object
- #batch_context ⇒ Object
- #bid ⇒ Object
- #deserialize(data) ⇒ Object
- #serialize ⇒ Object
- #valid_within_batch? ⇒ Boolean
Instance Method Details
#batch ⇒ Object
45 46 47 |
# File 'lib/joblin/batching/compat/active_job.rb', line 45 def batch Thread.current[CURRENT_BATCH_THREAD_KEY] end |
#batch_context ⇒ Object
49 50 51 |
# File 'lib/joblin/batching/compat/active_job.rb', line 49 def batch_context batch&.context || {} end |
#bid ⇒ Object
41 42 43 |
# File 'lib/joblin/batching/compat/active_job.rb', line 41 def bid @bid || Thread.current[CURRENT_BATCH_THREAD_KEY]&.bid end |
#deserialize(data) ⇒ Object
64 65 66 67 |
# File 'lib/joblin/batching/compat/active_job.rb', line 64 def deserialize(data) super @bid = data['batch_id'] end |
#serialize ⇒ Object
57 58 59 60 61 62 |
# File 'lib/joblin/batching/compat/active_job.rb', line 57 def serialize super.tap do |data| data['batch_id'] = @bid # This _must_ be @bid - not just bid data end end |
#valid_within_batch? ⇒ Boolean
53 54 55 |
# File 'lib/joblin/batching/compat/active_job.rb', line 53 def valid_within_batch? batch.valid? end |