Class: PeriodicJob::Scheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/periodic_job_mongoid/scheduler.rb

Instance Method Summary collapse

Constructor Details

#initializeScheduler

Returns a new instance of Scheduler.



6
7
8
# File 'lib/periodic_job_mongoid/scheduler.rb', line 6

def initialize
  @jobs = []
end

Instance Method Details

#after(&block) ⇒ Object



26
27
28
# File 'lib/periodic_job_mongoid/scheduler.rb', line 26

def after(&block)
  @after = block
end

#before(&block) ⇒ Object



22
23
24
# File 'lib/periodic_job_mongoid/scheduler.rb', line 22

def before(&block)
  @before = block
end

#error_handler(&block) ⇒ Object



18
19
20
# File 'lib/periodic_job_mongoid/scheduler.rb', line 18

def error_handler(&block)
  @error_handler = block
end

#every(interval, job_id, &block) ⇒ Object



10
11
12
# File 'lib/periodic_job_mongoid/scheduler.rb', line 10

def every(interval, job_id, &block)
  @jobs << Job.new(interval, job_id, block, @error_handler, @before, @after)
end

#tickObject



14
15
16
# File 'lib/periodic_job_mongoid/scheduler.rb', line 14

def tick
  @jobs.each &:tick
end