Class: Dynflow::ExecutionPlan::DependencyGraph

Inherits:
Object
  • Object
show all
Defined in:
lib/dynflow/execution_plan/dependency_graph.rb

Instance Method Summary collapse

Constructor Details

#initializeDependencyGraph

Returns a new instance of DependencyGraph.



4
5
6
# File 'lib/dynflow/execution_plan/dependency_graph.rb', line 4

def initialize
  @graph = Hash.new { |h, k| h[k] = Set.new }
end

Instance Method Details

#add_dependencies(step, action) ⇒ Object

adds dependencies to graph that step has based on the steps referenced in its input



10
11
12
13
14
# File 'lib/dynflow/execution_plan/dependency_graph.rb', line 10

def add_dependencies(step, action)
  action.required_step_ids.each do |required_step_id|
    @graph[step.id] << required_step_id
  end
end

#mark_satisfied(step_id, required_step_id) ⇒ Object



20
21
22
# File 'lib/dynflow/execution_plan/dependency_graph.rb', line 20

def mark_satisfied(step_id, required_step_id)
  @graph[step_id].delete(required_step_id)
end

#required_step_ids(step_id) ⇒ Object



16
17
18
# File 'lib/dynflow/execution_plan/dependency_graph.rb', line 16

def required_step_ids(step_id)
  @graph[step_id]
end

#unresolved?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/dynflow/execution_plan/dependency_graph.rb', line 24

def unresolved?
  @graph.any? { |step_id, required_step_ids| required_step_ids.any? }
end