Class: Pm::Process
Overview
Basic process
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #build_next_operations(old_operation) ⇒ Object
-
#initialize(config, context) ⇒ Process
constructor
A new instance of Process.
- #run_iteration ⇒ Object
- #start ⇒ Object
Methods included from ExtendableByTag
Constructor Details
#initialize(config, context) ⇒ Process
42 43 44 45 46 47 48 |
# File 'lib/flow.rb', line 42 def initialize(config, context) @config = config @context = context @operations = [] extend_by_tag end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
40 41 42 |
# File 'lib/flow.rb', line 40 def config @config end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
40 41 42 |
# File 'lib/flow.rb', line 40 def context @context end |
Instance Method Details
#build_next_operations(old_operation) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/flow.rb', line 71 def build_next_operations(old_operation) old_operation.config[old_operation.status].each do |operation_conf| operation_conf.each do |tag, _value| new_config = config['operations'].find { |o| o['tag'] == tag } new_operations = Operation.new(new_config, old_operation.context) @operations << new_operations end end end |
#run_iteration ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/flow.rb', line 58 def run_iteration next_operations = @operations.select(&:ready?) next_operations.map(&:complete) next_operations.map do |old_operation| next if old_operation.config[old_operation.status].nil? build_next_operations(old_operation) end run_iteration if @operations.any?(&:ready?) end |
#start ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/flow.rb', line 50 def start @operations = config['start'].map do |tag| new_config = config['operations'].find { |o| o['tag'] == tag } Operation.new(new_config, context) end run_iteration end |