lib/cloudist/worker.rb in cloudist-0.1.2 vs lib/cloudist/worker.rb in cloudist-0.2.0

- old
+ new

@@ -1,24 +1,33 @@ module Cloudist class Worker - attr_reader :options + attr_reader :job, :queue - def initialize(options) - @options = options + def initialize(job, queue) + @job, @queue = job, queue end + def data + job.data + end + + def headers + job.headers + end + + def process + raise NotImplementedError, "Your worker class must subclass this method" + end + def log Cloudist.log end - def job(queue_name, &block) - q = JobQueue.new(queue_name) - q.subscribe do |request| - j = Job.new(request.payload.dup) - j.instance_eval(&block) - j.cleanup - end + end + + class GenericWorker < Worker + def process(&block) + instance_eval(&block) end - end end