Class: Zizq::CrontabBuilder

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#targetObject (readonly)

The Crontab instance that this builder configures.



14
15
16
# File 'lib/zizq/crontab_builder.rb', line 14

def target
  @target
end

#timezoneObject

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