Sha256: 589189b3313b3ec1a758b3cbdfe91595fa38d036863b908356252628f6b1e04c

Contents?: true

Size: 822 Bytes

Versions: 4

Compression:

Stored size: 822 Bytes

Contents

require 'iconv'
require 'date'

module Afterparty
  class JobContainer
    attr_accessor :job, :raw, :execute_at, :job_id, :queue_name

    #intialized from redis's WITHSCORES function
    def initialize _raw, timestamp
      @execute_at = Time.at(timestamp)
      begin
        @job = Afterparty.load(_raw)
        @job_id = job.afterparty_job_id if @job.respond_to? :afterparty_job_id
        @queue_name = job.afterparty_queue if @job.respond_to? :afterparty_queue
      rescue Exception => e
        ap "Error during load: #{e.message}"
        @job = nil
      end
      @raw = _raw
      self
    end

    def job_class
      if @job
        @job.class
      else
        nil
      end
    end

    def raw_string
      ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
      ic.iconv(@raw.dup + ' ')[0..-2]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
afterparty-0.1.1 lib/afterparty/job_container.rb
afterparty-0.1.0 lib/afterparty/job_container.rb
afterparty-0.0.4 lib/afterparty/job_container.rb
afterparty-0.0.3 lib/afterparty/job_container.rb