Class: Wurk::Middleware::CurrentAttributes::Save
- Inherits:
-
Object
- Object
- Wurk::Middleware::CurrentAttributes::Save
- Includes:
- ServerMiddleware
- Defined in:
- lib/wurk/middleware/current_attributes.rb
Overview
Client-side: snapshot each registered CurrentAttributes class into
the job hash. Caller-supplied keys take precedence (||=), and a class
with nothing set adds no key, so the payload doesn't grow an empty one.
Instance Attribute Summary collapse
-
#config ⇒ Object
included
from ServerMiddleware
Returns the value of attribute config.
Instance Method Summary collapse
- #call(_job_class, job, _queue, _redis_pool) ⇒ Object
-
#initialize(classes) ⇒ Save
constructor
A new instance of Save.
- #logger ⇒ Object included from ServerMiddleware
- #redis(idempotent: false) ⇒ Object included from ServerMiddleware
- #redis_pool ⇒ Object included from ServerMiddleware
Constructor Details
#initialize(classes) ⇒ Save
Returns a new instance of Save.
72 73 74 |
# File 'lib/wurk/middleware/current_attributes.rb', line 72 def initialize(classes) @classes = classes end |
Instance Attribute Details
#config ⇒ Object Originally defined in module ServerMiddleware
Returns the value of attribute config.
Instance Method Details
#call(_job_class, job, _queue, _redis_pool) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/wurk/middleware/current_attributes.rb', line 76 def call(_job_class, job, _queue, _redis_pool) @classes.each_with_index do |reference, idx| attrs = CurrentAttributes.snapshot(CurrentAttributes.resolve(reference)) job[CurrentAttributes.key_for(idx)] ||= attrs unless attrs.empty? end yield end |