Class: Taskinator::TaskWorker

Inherits:
Object
  • Object
show all
Defined in:
lib/taskinator/task_worker.rb

Instance Method Summary collapse

Constructor Details

#initialize(uuid) ⇒ TaskWorker

Returns a new instance of TaskWorker.



3
4
5
# File 'lib/taskinator/task_worker.rb', line 3

def initialize(uuid)
  @uuid = uuid
end

Instance Method Details

#performObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/taskinator/task_worker.rb', line 7

def perform
  task = Taskinator::Task.fetch(@uuid)
  return if task.paused? || task.cancelled?
  begin
    task.start!
    task.complete! if task.can_complete?
  rescue Exception => e
    task.fail!(e)
  end
end