Class: Wurk::Cron::Manager
- Inherits:
-
Object
- Object
- Wurk::Cron::Manager
- Defined in:
- lib/wurk/cron.rb
Overview
Registration DSL. One Manager per ‘config.periodic` block; multiple blocks accumulate. `mgr.tz=` sets the default tz for subsequent `register` calls; per-call `tz:` overrides.
Instance Attribute Summary collapse
-
#loops ⇒ Object
readonly
Returns the value of attribute loops.
-
#tz ⇒ Object
Returns the value of attribute tz.
Instance Method Summary collapse
-
#initialize(config = nil) ⇒ Manager
constructor
A new instance of Manager.
- #register(cron, klass, **opts) ⇒ Object
Constructor Details
#initialize(config = nil) ⇒ Manager
Returns a new instance of Manager.
346 347 348 349 350 |
# File 'lib/wurk/cron.rb', line 346 def initialize(config = nil) @config = config @loops = [] @tz = nil end |
Instance Attribute Details
#loops ⇒ Object (readonly)
Returns the value of attribute loops.
344 345 346 |
# File 'lib/wurk/cron.rb', line 344 def loops @loops end |
#tz ⇒ Object
Returns the value of attribute tz.
343 344 345 |
# File 'lib/wurk/cron.rb', line 343 def tz @tz end |
Instance Method Details
#register(cron, klass, **opts) ⇒ Object
352 353 354 355 356 357 358 359 360 |
# File 'lib/wurk/cron.rb', line 352 def register(cron, klass, **opts) klass_name = klass.is_a?(String) ? klass : klass.to_s tz = opts.delete(:tz) || @tz normalized = opts.transform_keys(&:to_s) loop_obj = Loop.new(schedule: cron, klass: klass_name, options: normalized, tz: tz) @loops << loop_obj Cron.persist(loop_obj) loop_obj end |