Class: Sidekiq::Dry::Client::SerializationMiddleware
- Inherits:
-
Object
- Object
- Sidekiq::Dry::Client::SerializationMiddleware
- Defined in:
- lib/sidekiq/dry/client/serialization_middleware.rb
Overview
Middleware which converts ‘Dry::Struct` job arguments to hashes with a `_type` key to help deserializing back to the initial struct
Instance Method Summary collapse
Instance Method Details
#call(_worker_class, job, _queue, _redis_pool) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sidekiq/dry/client/serialization_middleware.rb', line 9 def call(_worker_class, job, _queue, _redis_pool) job['args'].map! do |arg| # Don't mutate non-struct arguments next arg unless arg.is_a? ::Dry::Struct # Set a `_type` argument to be able to instantiate # the struct when the job is performed arg.to_h.merge(_type: arg.class.to_s).as_json end yield end |