Sha256: 05ccaa7f828a62022a510dd2fc851ecedc795c4b4c45760ad50330a5ffd35287

Contents?: true

Size: 642 Bytes

Versions: 5

Compression:

Stored size: 642 Bytes

Contents

# frozen_string_literal: true

require "active_job/serializers/object_serializer"

module AcidicJob
  module Serializers
    class WorkerSerializer < ::ActiveJob::Serializers::ObjectSerializer
      def serialize(worker)
        super(
          "job_class" => worker.class.name
        )
      end

      def deserialize(hash)
        worker_class = hash["job_class"].constantize
        worker_class.new
      end

      def serialize?(argument)
        defined?(::Sidekiq) && argument.class.include?(::Sidekiq::Worker) &&
          !(defined?(::AcidicJob::ActiveKiq) && argument.class < ::AcidicJob::ActiveKiq)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
acidic_job-0.9.0 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-0.8.8 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-0.8.7 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-0.8.5 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-0.8.4 lib/acidic_job/serializers/worker_serializer.rb