Method: Taskmaster::Henchman::ClassMethods#every

Defined in:
lib/taskmaster/henchman.rb

#every(frequency, options = {}) ⇒ Object

Declares the cron job using whenever syntax.

Parameters:

  • frequency (Integer, #to_s)

    any frequency defined as valid for whenever (e.g., 600 (seconds), 1.day, :sunday, '0 12 * * *')

  • options (Hash) (defaults to: {})

    configuration options

Options Hash (options):

  • :run (Symbol) — default: :run

    the class method to call in the cron job

  • :with (Symbol) — default: :runner

    the whenever job type to use when defining the cron job

  • :at (Integer, #to_s)

    a specific time to start the cron job (e.g., every :hour, :at => 6' runs a job 6 minutes after every hour;every :day, :at => '4:30 am' runs a job at 4:30 am every day.)



24
25
26
27
28
29
30
31
# File 'lib/taskmaster/henchman.rb', line 24

def every(frequency, options = {})
  @scheduled_jobs ||= []
  method  = options.delete(:run) || :run
  command = options.delete(:with) || :runner
  @scheduled_jobs << "every #{frequency.to_s}, #{options.inspect} do
  #{command.to_s} \'#{self.name}.#{method.to_s}\'
end"
end