Class: Resque::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/resque/task.rb,
lib/resque/task/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, status) ⇒ Task

Returns a new instance of Task.



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

def initialize(options={}, status)
  options['parent'] = options.delete('class')
  options.each do |opt, val|
    self.send("#{opt}=", val)
  end
  if payload
    self.parent = payload['class']
    self.args = payload['args']
  end

  self.status = status
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



6
7
8
# File 'lib/resque/task.rb', line 6

def args
  @args
end

#backtraceObject

Returns the value of attribute backtrace.



7
8
9
# File 'lib/resque/task.rb', line 7

def backtrace
  @backtrace
end

#errorObject

Returns the value of attribute error.



7
8
9
# File 'lib/resque/task.rb', line 7

def error
  @error
end

#exceptionObject

Returns the value of attribute exception.



7
8
9
# File 'lib/resque/task.rb', line 7

def exception
  @exception
end

#failed_atObject

Returns the value of attribute failed_at.



8
9
10
# File 'lib/resque/task.rb', line 8

def failed_at
  @failed_at
end

#parentObject

Returns the value of attribute parent.



6
7
8
# File 'lib/resque/task.rb', line 6

def parent
  @parent
end

#payloadObject

Returns the value of attribute payload.



7
8
9
# File 'lib/resque/task.rb', line 7

def payload
  @payload
end

#queueObject

Returns the value of attribute queue.



7
8
9
# File 'lib/resque/task.rb', line 7

def queue
  @queue
end

#retried_atObject

Returns the value of attribute retried_at.



8
9
10
# File 'lib/resque/task.rb', line 8

def retried_at
  @retried_at
end

#run_atObject

Returns the value of attribute run_at.



8
9
10
# File 'lib/resque/task.rb', line 8

def run_at
  @run_at
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/resque/task.rb', line 6

def status
  @status
end

#workerObject

Returns the value of attribute worker.



7
8
9
# File 'lib/resque/task.rb', line 7

def worker
  @worker
end

Class Method Details

.allObject



40
41
42
# File 'lib/resque/task.rb', line 40

def all
  [working, queued, failed].flatten
end

.failed(finish = 10000) ⇒ Object



28
29
30
# File 'lib/resque/task.rb', line 28

def failed(finish=10000)
  Resque::Failure.all(0, finish).map {|failure| Resque::Task.new(failure, :failed) }
end

.queued(finish = 10000) ⇒ Object



36
37
38
# File 'lib/resque/task.rb', line 36

def queued(finish=10000)
  Resque.queues.map {|e| Resque.peek(e, 0, finish) }.flatten.map {|task| Resque::Task.new(task, :queued) }
end

.working(finish = 10000) ⇒ Object



32
33
34
# File 'lib/resque/task.rb', line 32

def working(finish=10000)
  Resque.working.map {|task| Resque::Task.new(task.job, :working) }
end