Sha256: a5299344d7ae908b78aebff8a075d6f03145ef49a8ef00a3646732767fdc9214
Contents?: true
Size: 760 Bytes
Versions: 62
Compression:
Stored size: 760 Bytes
Contents
module Workarea class Scheduler attr_reader :job_id def self.schedule(*args) instance = new(*args) instance.perform instance.job_id end def self.delete(job_id) new(job_id: job_id).delete end def initialize(options = {}) @time = options[:at] @worker = options[:worker] @args = options[:args] @job_id = options[:job_id] end def perform delete add_job end def delete current_job.try(:delete) end def add_job @job_id = @worker.perform_at(@time, *@args) end private def current_job return nil if job_id.blank? @current_job ||= Sidekiq::ScheduledSet.new.detect { |j| j.jid == job_id } end end end
Version data entries
62 entries across 62 versions & 1 rubygems