Sha256: 387b2ad9d49f594068e6c6a7fbd3de6ab5524d2d36facc1431f416b13b7988f2

Contents?: true

Size: 806 Bytes

Versions: 8

Compression:

Stored size: 806 Bytes

Contents

# frozen_string_literal: true

module AdvancedSneakersActiveJob
  module ActiveJobPatch
    extend ActiveSupport::Concern

    included do
      # AMQP message contains metadata which might be helpful for consumer (e.g. job.delivery_info.routing_key)
      attr_accessor :delivery_info, :headers

      class_attribute :publish_options, instance_accessor: false
    end

    module ClassMethods
      def deserialize(job_data)
        super(job_data).tap do |job|
          job.delivery_info = job_data['delivery_info']
          job.headers = job_data['headers']
        end
      end

      def message_options(options)
        raise ArgumentError, 'message_options accepts Hash argument only' unless options.is_a?(Hash)

        self.publish_options = options.symbolize_keys
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
advanced-sneakers-activejob-0.3.6 lib/advanced_sneakers_activejob/active_job_patch.rb
advanced-sneakers-activejob-0.3.5 lib/advanced_sneakers_activejob/active_job_patch.rb
advanced-sneakers-activejob-0.3.4 lib/advanced_sneakers_activejob/active_job_patch.rb
advanced-sneakers-activejob-0.3.3 lib/advanced_sneakers_activejob/active_job_patch.rb
advanced-sneakers-activejob-0.3.2 lib/advanced_sneakers_activejob/active_job_patch.rb
advanced-sneakers-activejob-0.3.1 lib/advanced_sneakers_activejob/active_job_patch.rb
advanced-sneakers-activejob-0.3.0 lib/advanced_sneakers_activejob/active_job_patch.rb
advanced-sneakers-activejob-0.2.3 lib/advanced_sneakers_activejob/active_job_patch.rb