Class: Swarm::Process
Instance Attribute Summary
Attributes inherited from HiveDweller
#hive, #id
Instance Method Summary
collapse
Methods inherited from HiveDweller
#==, all, #attributes, #change_attribute, #changed?, create, #delete, each, fetch, ids, inherited, #initialize, many_to_one, #new?, new_from_storage, #reload!, #save, #set_attributes, set_columns, #storage, #storage_id, storage_id_for_key, storage_type, #to_hash
Instance Method Details
#_launch ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/swarm/process.rb', line 18
def _launch
root_expression = SequenceExpression.create(
:hive => hive,
:parent_id => id,
:position => [0],
:workitem => workitem,
:process_id => id
)
root_expression.apply
self.root_expression_id = root_expression.id
save
end
|
#finished? ⇒ Boolean
40
41
42
|
# File 'lib/swarm/process.rb', line 40
def finished?
root_expression && root_expression.replied?
end
|
#launch ⇒ Object
13
14
15
16
|
# File 'lib/swarm/process.rb', line 13
def launch
hive.queue('launch', self)
self
end
|
#move_on_from(expression) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/swarm/process.rb', line 49
def move_on_from(expression)
self.workitem = expression.workitem
save
if parent_expression
parent_expression.move_on_from(self)
end
end
|
#node_at_position(position) ⇒ Object
44
45
46
47
|
# File 'lib/swarm/process.rb', line 44
def node_at_position(position)
raise ArgumentError unless position == 0
process_definition.tree
end
|
#root_expression ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/swarm/process.rb', line 31
def root_expression
@root_expression ||= begin
reload! unless root_expression_id
if root_expression_id
Expression.fetch(root_expression_id, hive: hive)
end
end
end
|
#wait_until_finished(timeout: 5) ⇒ Object
9
10
11
|
# File 'lib/swarm/process.rb', line 9
def wait_until_finished(timeout: 5)
Swarm::Support.wait_until(timeout: timeout) { finished? }
end
|