Sha256: be3194da2ec10dc8b1a7e038d42f2c347cc5f2e87c9042f1133acb8926150834
Contents?: true
Size: 1015 Bytes
Versions: 1
Compression:
Stored size: 1015 Bytes
Contents
class Karousel class Job attr_reader :client_job STATUS = { init: 1, sent: 2, success: 3, failure: 4 } def initialize(client_job) raise TypeError.new("Unknown client job type") unless client_job.is_a?(Karousel::ClientJob) @client_job = client_job end def status @status = @client_job.status unless [1,2,3,4].include?(@status) raise TypeError.new('Status must be an integer between 1 and 4') end @status end def status= (new_status) unless [1,2,3,4].include?(new_status) raise TypeError.new('Status must be an integer between 1 and 4') end @client_job.status = new_status end def send is_ok = @client_job.send self.status = (is_ok ? STATUS[:sent] : STATUS[:failure]) is_ok end def finished? @client_job.finished? end def process is_ok = @client_job.process self.status = (is_ok ? STATUS[:success] : STATUS[:failure]) is_ok end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
karousel-0.9.13 | lib/karousel/job.rb |