Module: Quartz::Scheduler::InstanceMethods

Defined in:
lib/quartz/scheduler.rb

Instance Method Summary collapse

Instance Method Details

#defaultsObject



47
48
49
50
51
# File 'lib/quartz/scheduler.rb', line 47

def defaults
  {
    :at=>0
  }
end

#job_factoryObject



58
59
60
# File 'lib/quartz/scheduler.rb', line 58

def job_factory
  JobFactory.instance
end

#runObject



61
62
63
# File 'lib/quartz/scheduler.rb', line 61

def run
  scheduler.start
end

#schedule(name, options, block) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/quartz/scheduler.rb', line 38

def schedule(name, options, block)
  options=defaults.merge options
  job_factory.jobs[name.to_s] = block
  job_detail = JobDetail.new(name.to_s, "cronjob",CronJob.new(name.to_s))
  cron_expression = Cronify.cronify(options[:every],options[:at])
  trigger=CronTrigger.new("#{name.to_s}_crontrig","cront_trig_group",name.to_s,"cronjob",cron_expression)
  scheduler.set_job_factory(job_factory)
  scheduler.schedule_job(job_detail,trigger)
end

#schedulerObject



55
56
57
# File 'lib/quartz/scheduler.rb', line 55

def scheduler
  scheduler_factory.get_scheduler
end

#scheduler_factoryObject



52
53
54
# File 'lib/quartz/scheduler.rb', line 52

def scheduler_factory
  @scheduler_factor ||= StdSchedulerFactory.new
end