Class: SidekiqCurrentModelMiddleware::Load
- Inherits:
-
Object
- Object
- SidekiqCurrentModelMiddleware::Load
- Includes:
- Sidekiq::ServerMiddleware
- Defined in:
- lib/sidekiq_current_model_middleware.rb
Overview
Load class
Server middleware that loads CurrentAttributes from the Sidekiq job payload. It handles deserialization of ActiveRecord models using GlobalID.
Instance Method Summary collapse
- #call(_, job, _, &block) ⇒ Object
-
#initialize(cattrs) ⇒ Load
constructor
Initialize the Load middleware.
Constructor Details
#initialize(cattrs) ⇒ Load
Initialize the Load middleware
95 96 97 |
# File 'lib/sidekiq_current_model_middleware.rb', line 95 def initialize(cattrs) @cattrs = cattrs end |
Instance Method Details
#call(_, job, _, &block) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/sidekiq_current_model_middleware.rb', line 99 def call(_, job, _, &block) klass_attrs = {} @cattrs.each do |(key, strklass)| next unless job.key?(key) klass_attrs[strklass.constantize] = job[key] end wrap(klass_attrs.to_a, &block) end |