Class: Dynflow::Flows::AbstractComposed
- Inherits:
-
Abstract
- Object
- Serializable
- Abstract
- Dynflow::Flows::AbstractComposed
- Defined in:
- lib/dynflow/flows/abstract_composed.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#flows ⇒ Object
(also: #sub_flows)
readonly
Returns the value of attribute flows.
Instance Method Summary collapse
- #<<(v) ⇒ Object
- #[](*args) ⇒ Object
- #[]=(*args) ⇒ Object
- #add_and_resolve(dependency_graph, new_flow) ⇒ Object
-
#all_step_ids ⇒ Array<Integer>
All step_ids recursively in the flow.
- #flatten! ⇒ Object
-
#initialize(flows) ⇒ AbstractComposed
constructor
A new instance of AbstractComposed.
- #size ⇒ Object
- #to_hash ⇒ Object
Methods inherited from Abstract
Methods inherited from Serializable
Constructor Details
#initialize(flows) ⇒ AbstractComposed
Returns a new instance of AbstractComposed.
7 8 9 10 11 |
# File 'lib/dynflow/flows/abstract_composed.rb', line 7 def initialize(flows) Type! flows, Array flows.all? { |f| Type! f, Abstract } @flows = flows end |
Instance Attribute Details
#flows ⇒ Object (readonly) Also known as: sub_flows
Returns the value of attribute flows.
5 6 7 |
# File 'lib/dynflow/flows/abstract_composed.rb', line 5 def flows @flows end |
Instance Method Details
#<<(v) ⇒ Object
17 18 19 20 |
# File 'lib/dynflow/flows/abstract_composed.rb', line 17 def <<(v) @flows << v self end |
#[](*args) ⇒ Object
22 23 24 |
# File 'lib/dynflow/flows/abstract_composed.rb', line 22 def [](*args) @flows[*args] end |
#[]=(*args) ⇒ Object
26 27 28 |
# File 'lib/dynflow/flows/abstract_composed.rb', line 26 def []=(*args) @flows.[]=(*args) end |
#add_and_resolve(dependency_graph, new_flow) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/dynflow/flows/abstract_composed.rb', line 41 def add_and_resolve(dependency_graph, new_flow) return if new_flow.empty? = (dependency_graph, new_flow) add_to_sequence(, new_flow) flatten! end |
#all_step_ids ⇒ Array<Integer>
Returns all step_ids recursively in the flow.
37 38 39 |
# File 'lib/dynflow/flows/abstract_composed.rb', line 37 def all_step_ids flows.map(&:all_step_ids).flatten end |
#flatten! ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/dynflow/flows/abstract_composed.rb', line 49 def flatten! self.sub_flows.to_enum.with_index.reverse_each do |flow, i| if flow.class == self.class (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
30 31 32 |
# File 'lib/dynflow/flows/abstract_composed.rb', line 30 def size @flows.size end |
#to_hash ⇒ Object
13 14 15 |
# File 'lib/dynflow/flows/abstract_composed.rb', line 13 def to_hash super.merge recursive_to_hash(:flows => flows) end |