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.



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

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



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

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



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

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

#required_step_ids(step_id) ⇒ Object



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

def required_step_ids(step_id)
  @graph[step_id]
end

#unresolved?Boolean

Returns:

  • (Boolean)


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

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