Sha256: 8ec3ec160360a95edc165b52ad8c5395f632026fc0f2f4582ed72b5d37c04e36
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
require 'active_record' require 'afterparty/queue_helpers' class AfterpartyJob < ::ActiveRecord::Base # include Afterparty::QueueHelpers validates_presence_of :job_dump, :execute_at, :queue scope :namespaced, lambda { |name| where(queue: name) if name } scope :incomplete, -> { where(completed: false).order("execute_at") } scope :valid, -> { incomplete.where(execute_at: 10.years.ago..DateTime.now) } scope :completed, -> { where(completed: true).order("execute_at desc") } def self.make_with_job job, queue=:default afterparty_job = AfterpartyJob.new afterparty_job.job_dump = job.to_yaml afterparty_job.execute_at = Afterparty.queue_time(job) afterparty_job.queue = queue afterparty_job.completed = false afterparty_job.save afterparty_job end def reify Afterparty.load(job_dump) end def execute if (j = reify) j.run end end # def self.namespaced name # where(queue: name) # end # def namespaced name # where(queue: name) # end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
afterparty-0.2.0 | lib/afterparty/afterparty_job.rb |