Module: Karafka::ActiveJob::CurrentAttributes::Loading
- Defined in:
- lib/karafka/active_job/current_attributes/loading.rb
Overview
Module expanding the job deserialization to extract current attributes and load them for the time of the job execution
Instance Method Summary collapse
Instance Method Details
#with_deserialized_job(job_message) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/karafka/active_job/current_attributes/loading.rb', line 10 def with_deserialized_job() super() do |job| resetable = [] _cattr_klasses.each do |key, cattr_klass_str| next unless job.key?(key) attributes = job.delete(key) cattr_klass = cattr_klass_str.constantize attributes.each do |name, value| cattr_klass.public_send("#{name}=", value) end resetable << cattr_klass end yield(job) resetable.each(&:reset) end end |