Class: Zizq::CrontabBuilder
- Inherits:
-
Object
- Object
- Zizq::CrontabBuilder
- Defined in:
- lib/zizq/crontab_builder.rb
Overview
Builder used to configure a Zizq::Crontab instance.
Instances of this class are returned from ‘Zizq.define_crontab`. See documentation for that method for usage.
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
The Crontab instance that this builder configures.
-
#timezone ⇒ Object
Optional timezone to be applied to all entries by default.
Instance Method Summary collapse
-
#define_entry(name, expression, timezone: self.timezone, paused: nil) ⇒ Object
Add or replace an entry on the schedule.
-
#initialize(target, timezone: nil, paused: nil) ⇒ CrontabBuilder
constructor
Initialize the builder with the given Crontab instance.
Constructor Details
#initialize(target, timezone: nil, paused: nil) ⇒ CrontabBuilder
Initialize the builder with the given Crontab instance.
24 25 26 27 28 29 |
# File 'lib/zizq/crontab_builder.rb', line 24 def initialize(target, timezone: nil, paused: nil) @target = target.clear @timezone = timezone target.paused = paused end |
Instance Attribute Details
#target ⇒ Object (readonly)
The Crontab instance that this builder configures.
14 15 16 |
# File 'lib/zizq/crontab_builder.rb', line 14 def target @target end |
#timezone ⇒ Object
Optional timezone to be applied to all entries by default.
17 18 19 |
# File 'lib/zizq/crontab_builder.rb', line 17 def timezone @timezone end |
Instance Method Details
#define_entry(name, expression, timezone: self.timezone, paused: nil) ⇒ Object
Add or replace an entry on the schedule
If no entry with the given name exists, it is added to schedule. If an entry with the same name exist, this entry replaces that entry. If the entry is the same as the original, the result is idempotent.
42 43 44 45 46 47 48 49 50 |
# File 'lib/zizq/crontab_builder.rb', line 42 def define_entry(name, expression, timezone: self.timezone, paused: nil) CrontabEntryBuilder.new( target, name, expression, timezone:, paused:, ) end |