Sha256: 5b52166a22f79f9fb68909b87bc74f2650bc7c013ba712c2c692602c1902f5d4
Contents?: true
Size: 933 Bytes
Versions: 9
Compression:
Stored size: 933 Bytes
Contents
require 'delayed_job' module DelayedCron module Jobs class DelayedJob < Struct.new(:klass, :method_name, :options) def self.enqueue_delayed_cron(klass, method_name, options) unless scheduled?(klass, method_name) options.symbolize_keys! ::Delayed::Job.enqueue( :payload_object => new(klass, method_name, options), :run_at => Time.now + options[:interval], :queue => :cron_job ) end end def self.scheduled?(klass, method_name) scheduled = false ::Delayed::Job.where(:queue => :cron_job).each do |job| obj = YAML.load_dj(job.handler) scheduled = true if obj["klass"] == klass && obj["method_name"] == method_name end scheduled end def perform(klass, method_name, options) DelayedCron.process_job(klass, method_name, options) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems