Sha256: 420b26093949a1a26d83cb1f3bd6eee63410ffcc420c6aa57f35e7176d036475

Contents?: true

Size: 940 Bytes

Versions: 58

Compression:

Stored size: 940 Bytes

Contents

# frozen_string_literal: true

module Karafka
  module ActiveJob
    module CurrentAttributes
      # Module expanding the job deserialization to extract current attributes and load them
      # for the time of the job execution
      module Loading
        # @param job_message [Karafka::Messages::Message] message with active job
        def with_deserialized_job(job_message)
          super(job_message) 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
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
karafka-2.3.3 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.3.2 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.3.1 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.3.0 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.3.0.rc1 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.3.0.alpha2 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.3.0.alpha1 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.14 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.13 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.12 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.11 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.10 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.9 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.8 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.8.beta1 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.7 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.6 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.5 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.4 lib/karafka/active_job/current_attributes/loading.rb
karafka-2.2.3 lib/karafka/active_job/current_attributes/loading.rb