Sha256: 4a85644c2a9715545806785e06eb809e2d88dc5c9b9eef268e5e31501079e045

Contents?: true

Size: 634 Bytes

Versions: 14

Compression:

Stored size: 634 Bytes

Contents

# frozen_string_literal: true

require "active_job/serializers/object_serializer"

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

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

      def serialize?(argument)
        defined?(::Sidekiq) && argument.class.include?(::Sidekiq::Worker)
      end
    end
  end
end
# :nocov:

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
acidic_job-0.8.3 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-0.8.2 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-0.8.1 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-0.8.0 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-1.0.0.beta.10 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-1.0.0.beta.9 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-1.0.0.beta.8 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-1.0.0.beta.7 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-1.0.0.beta.6 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-1.0.0.beta.5 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-1.0.0.beta.4 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-1.0.0.beta.3 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-1.0.0.beta.2 lib/acidic_job/serializers/worker_serializer.rb
acidic_job-1.0.0.beta.1 lib/acidic_job/serializers/worker_serializer.rb