Sha256: e5200a255290b3f991dfdebf7965869d71b652f6081610844b2b984fa3394b7d
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
module DCA module Jobs class Job include Helpers::Logger logger_name :queue attr_reader :options def self.queue self.to_s.split("::")[-2] end # Add a job to queue. Queue name is a class module name def self.create(options={}) Resque.enqueue(self, options) end def self.perform(options={}) instance = new options.symbolize_keys! instance.safe_perform! instance end def initialize(options = {}) @options = options trap('QUIT') { shutdown } end def safe_perform! perform on_success if respond_to?(:on_success) rescue Exception => exception if respond_to?(:on_failure) on_failure(exception) else raise exception end ensure destroy end def perform raise NotImplementedError end def destroy end def shutdown? @shutdown end private def shutdown @shutdown = true end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dca-0.1.1 | lib/dca/jobs/job.rb |
dca-0.1.0 | lib/dca/jobs/job.rb |