Class: AcidicJob::Serializers::WorkerSerializer

Inherits:
ActiveJob::Serializers::ObjectSerializer
  • Object
show all
Defined in:
lib/acidic_job/serializers/worker_serializer.rb

Instance Method Summary collapse

Instance Method Details

#deserialize(hash) ⇒ Object



14
15
16
17
# File 'lib/acidic_job/serializers/worker_serializer.rb', line 14

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

#serialize(worker) ⇒ Object



8
9
10
11
12
# File 'lib/acidic_job/serializers/worker_serializer.rb', line 8

def serialize(worker)
  super(
    "job_class" => worker.class.name
  )
end

#serialize?(argument) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/acidic_job/serializers/worker_serializer.rb', line 19

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