Sha256: c8c1e0397d11381255bb56210ae226234bc59c038c362c368942f12e41e4951e

Contents?: true

Size: 651 Bytes

Versions: 4

Compression:

Stored size: 651 Bytes

Contents

module Cloudist
  class Worker
    
    attr_reader :job, :queue, :payload
    
    def initialize(job, queue)
      @job, @queue, @payload = job, queue, job.payload
      
      # Do custom initialization
      self.setup if self.respond_to?(:setup)
    end
    
    def data
      job.data
    end
    
    def headers
      job.headers
    end
    
    def id
      job.id
    end
    
    def process
      raise NotImplementedError, "Your worker class must subclass this method"
    end
    
    def log
      Cloudist.log
    end
    
  end
  
  class GenericWorker < Worker
    def process(&block)
      instance_eval(&block)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cloudist-0.4.4 lib/cloudist/worker.rb
cloudist-0.4.3 lib/cloudist/worker.rb
cloudist-0.4.2 lib/cloudist/worker.rb
cloudist-0.4.1 lib/cloudist/worker.rb