Module: Taskmaster::Henchman::ClassMethods
- Defined in:
- lib/taskmaster/henchman.rb
Instance Method Summary collapse
-
#cron_output ⇒ String
Cron syntax generated from the jobs scheduled in the including class.
-
#every(frequency, options = {}) ⇒ Object
Declares the cron job using
whenever
syntax. -
#run ⇒ Object
Must be overridden by including classes.
-
#scheduled_jobs ⇒ Array
Jobs scheduled by the including class.
Instance Method Details
#cron_output ⇒ String
Cron syntax generated from the jobs scheduled in the including class
41 42 43 |
# File 'lib/taskmaster/henchman.rb', line 41 def cron_output Whenever::JobList.new(@scheduled_jobs.join("\n")).generate_cron_output end |
#every(frequency, options = {}) ⇒ Object
Declares the cron job using whenever
syntax.
24 25 26 27 28 29 30 31 |
# File 'lib/taskmaster/henchman.rb', line 24 def every(frequency, = {}) @scheduled_jobs ||= [] method = .delete(:run) || :run command = .delete(:with) || :runner @scheduled_jobs << "every #{frequency.to_s}, #{.inspect} do #{command.to_s} \'#{self.name}.#{method.to_s}\' end" end |
#run ⇒ Object
Must be overridden by including classes
34 35 36 |
# File 'lib/taskmaster/henchman.rb', line 34 def run raise 'Not implemented' end |
#scheduled_jobs ⇒ Array
Jobs scheduled by the including class
48 49 50 |
# File 'lib/taskmaster/henchman.rb', line 48 def scheduled_jobs @scheduled_jobs end |