Class: Afterparty::JobContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/afterparty/job_container.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_raw, timestamp) ⇒ JobContainer

intialized from redis’s WITHSCORES function



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/afterparty/job_container.rb', line 9

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

Instance Attribute Details

#execute_atObject

Returns the value of attribute execute_at.



6
7
8
# File 'lib/afterparty/job_container.rb', line 6

def execute_at
  @execute_at
end

#jobObject

Returns the value of attribute job.



6
7
8
# File 'lib/afterparty/job_container.rb', line 6

def job
  @job
end

#job_idObject

Returns the value of attribute job_id.



6
7
8
# File 'lib/afterparty/job_container.rb', line 6

def job_id
  @job_id
end

#queue_nameObject

Returns the value of attribute queue_name.



6
7
8
# File 'lib/afterparty/job_container.rb', line 6

def queue_name
  @queue_name
end

#rawObject

Returns the value of attribute raw.



6
7
8
# File 'lib/afterparty/job_container.rb', line 6

def raw
  @raw
end

Instance Method Details

#job_classObject



23
24
25
26
27
28
29
# File 'lib/afterparty/job_container.rb', line 23

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

#raw_stringObject



31
32
33
34
# File 'lib/afterparty/job_container.rb', line 31

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