Class: Taskinator::Process
- Inherits:
-
Object
- Object
- Taskinator::Process
show all
- Includes:
- Comparable, Persistence, Workflow
- Defined in:
- lib/taskinator/process.rb
Defined Under Namespace
Classes: Concurrent, Sequential
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
add_process_to_list, included, list_key
Constructor Details
#initialize(definition, options = {}) ⇒ Process
Returns a new instance of Process.
27
28
29
30
31
32
33
34
|
# File 'lib/taskinator/process.rb', line 27
def initialize(definition, options={})
raise ArgumentError, 'definition' if definition.nil?
raise ArgumentError, "#{definition.name} does not extend the #{Definition.name} module" unless definition.kind_of?(Definition)
@uuid = SecureRandom.uuid
@definition = definition
@options = options
end
|
Instance Attribute Details
#definition ⇒ Object
Returns the value of attribute definition.
21
22
23
|
# File 'lib/taskinator/process.rb', line 21
def definition
@definition
end
|
#options ⇒ Object
Returns the value of attribute options.
22
23
24
|
# File 'lib/taskinator/process.rb', line 22
def options
@options
end
|
#parent ⇒ Object
in the case of sub process tasks, the containing task
25
26
27
|
# File 'lib/taskinator/process.rb', line 25
def parent
@parent
end
|
#uuid ⇒ Object
Returns the value of attribute uuid.
20
21
22
|
# File 'lib/taskinator/process.rb', line 20
def uuid
@uuid
end
|
Class Method Details
.base_key ⇒ Object
15
16
17
|
# File 'lib/taskinator/process.rb', line 15
def base_key
'process'
end
|
.define_concurrent_process_for(definition, complete_on = CompleteOn::Default, options = {}) ⇒ Object
11
12
13
|
# File 'lib/taskinator/process.rb', line 11
def define_concurrent_process_for(definition, complete_on=CompleteOn::Default, options={})
Process::Concurrent.new(definition, complete_on, options)
end
|
.define_sequential_process_for(definition, options = {}) ⇒ Object
7
8
9
|
# File 'lib/taskinator/process.rb', line 7
def define_sequential_process_for(definition, options={})
Process::Sequential.new(definition, options)
end
|
Instance Method Details
#<=>(other) ⇒ Object
48
49
50
|
# File 'lib/taskinator/process.rb', line 48
def <=>(other)
uuid <=> other.uuid
end
|
#accept(visitor) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/taskinator/process.rb', line 40
def accept(visitor)
visitor.visit_attribute(:uuid)
visitor.visit_task_reference(:parent)
visitor.visit_type(:definition)
visitor.visit_tasks(tasks)
visitor.visit_args(:options)
end
|
#enqueue ⇒ Object
125
126
127
|
# File 'lib/taskinator/process.rb', line 125
def enqueue
Taskinator.queue.enqueue_process(self)
end
|
#no_tasks_defined? ⇒ Boolean
106
107
108
|
# File 'lib/taskinator/process.rb', line 106
def no_tasks_defined?
tasks.empty?
end
|
#on_completed_entry(*args) ⇒ Object
callback for when the process has completed
130
131
132
133
134
|
# File 'lib/taskinator/process.rb', line 130
def on_completed_entry(*args)
parent.complete! unless parent.nil?
end
|
#on_failed_entry(*args) ⇒ Object
callback for when the process has failed
137
138
139
140
141
|
# File 'lib/taskinator/process.rb', line 137
def on_failed_entry(*args)
parent.fail!(*args) unless parent.nil?
end
|
#queue ⇒ Object
56
57
58
|
# File 'lib/taskinator/process.rb', line 56
def queue
options[:queue]
end
|
#task_failed(task, error) ⇒ Object
115
116
117
118
|
# File 'lib/taskinator/process.rb', line 115
def task_failed(task, error)
fail!(error)
end
|
#tasks ⇒ Object
36
37
38
|
# File 'lib/taskinator/process.rb', line 36
def tasks
@tasks ||= Tasks.new()
end
|
#tasks_completed?(*args) ⇒ Boolean
110
111
112
113
|
# File 'lib/taskinator/process.rb', line 110
def tasks_completed?(*args)
raise NotImplementedError
end
|
#to_s ⇒ Object
52
53
54
|
# File 'lib/taskinator/process.rb', line 52
def to_s
"#<#{self.class.name}:#{uuid}>"
end
|