Class: Taskinator::TaskWorker

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uuid) ⇒ TaskWorker

Returns a new instance of TaskWorker.



5
6
7
# File 'lib/taskinator/task_worker.rb', line 5

def initialize(uuid)
  @uuid = uuid
end

Instance Attribute Details

#uuidObject (readonly)

Returns the value of attribute uuid.



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

def uuid
  @uuid
end

Instance Method Details

#performObject



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

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