Class: Taskinator::Process::Sequential

Inherits:
Taskinator::Process show all
Defined in:
lib/taskinator/process.rb

Instance Attribute Summary

Attributes inherited from Taskinator::Process

#definition, #options, #parent, #queue, #uuid

Instance Method Summary collapse

Methods inherited from Taskinator::Process

#<=>, #accept, base_key, define_concurrent_process_for, define_sequential_process_for, #enqueue, #initialize, #no_tasks_defined?, #on_completed_entry, #on_failed_entry, #reload, #task_failed, #tasks, #to_s

Methods included from Taskinator::Persistence

add_process_to_list, deserialize, included, list_key, serialize

Constructor Details

This class inherits a constructor from Taskinator::Process

Instance Method Details

#startObject



143
144
145
146
147
148
149
150
# File 'lib/taskinator/process.rb', line 143

def start
  task = tasks.first
  if task
    task.enqueue!
  else
    complete! # weren't any tasks to start with
  end
end

#task_completed(task) ⇒ Object



152
153
154
155
156
157
158
159
# File 'lib/taskinator/process.rb', line 152

def task_completed(task)
  next_task = task.next
  if next_task
    next_task.enqueue!
  else
    complete! if can_complete?
  end
end

#tasks_completed?(*args) ⇒ Boolean

Returns:

  • (Boolean)


161
162
163
164
# File 'lib/taskinator/process.rb', line 161

def tasks_completed?(*args)
  # TODO: optimize this
  tasks.all?(&:completed?)
end