Class: Dynflow::Flows::AbstractComposed
Constant Summary
Constants inherited
from Serializable
Serializable::LEGACY_TIME_FORMAT, Serializable::TIME_FORMAT
Instance Attribute Summary collapse
-
#flows ⇒ Object
(also: #sub_flows)
readonly
Returns the value of attribute flows.
Instance Method Summary
collapse
Methods inherited from Abstract
decode, #empty?, #includes_step?, new_from_hash, #to_hash
constantize, from_hash, new_from_hash, #to_hash
Constructor Details
Returns a new instance of AbstractComposed.
8
9
10
11
12
|
# File 'lib/dynflow/flows/abstract_composed.rb', line 8
def initialize(flows)
Type! flows, Array
flows.all? { |f| Type! f, Abstract }
@flows = flows
end
|
Instance Attribute Details
#flows ⇒ Object
Also known as:
sub_flows
Returns the value of attribute flows.
6
7
8
|
# File 'lib/dynflow/flows/abstract_composed.rb', line 6
def flows
@flows
end
|
Instance Method Details
#<<(v) ⇒ Object
18
19
20
21
|
# File 'lib/dynflow/flows/abstract_composed.rb', line 18
def <<(v)
@flows << v
self
end
|
#[](*args) ⇒ Object
23
24
25
|
# File 'lib/dynflow/flows/abstract_composed.rb', line 23
def [](*args)
@flows[*args]
end
|
#[]=(*args) ⇒ Object
27
28
29
|
# File 'lib/dynflow/flows/abstract_composed.rb', line 27
def []=(*args)
@flows.[]=(*args)
end
|
#add_and_resolve(dependency_graph, new_flow) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/dynflow/flows/abstract_composed.rb', line 42
def add_and_resolve(dependency_graph, new_flow)
return if new_flow.empty?
satisfying_flows = find_satisfying_sub_flows(dependency_graph, new_flow)
add_to_sequence(satisfying_flows, new_flow)
flatten!
end
|
#all_step_ids ⇒ Array<Integer>
Returns all step_ids recursively in the flow.
38
39
40
|
# File 'lib/dynflow/flows/abstract_composed.rb', line 38
def all_step_ids
flows.map(&:all_step_ids).flatten
end
|
#encode ⇒ Object
14
15
16
|
# File 'lib/dynflow/flows/abstract_composed.rb', line 14
def encode
[Registry.encode(self)] + flows.map(&:encode)
end
|
#flatten! ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/dynflow/flows/abstract_composed.rb', line 50
def flatten!
self.sub_flows.to_enum.with_index.reverse_each do |flow, i|
if flow.class == self.class
expand_steps(i)
elsif flow.is_a?(AbstractComposed) && flow.sub_flows.size == 1
self.sub_flows[i] = flow.sub_flows.first
end
end
self.sub_flows.map(&:flatten!)
end
|
#size ⇒ Object
31
32
33
|
# File 'lib/dynflow/flows/abstract_composed.rb', line 31
def size
@flows.size
end
|