Module: Aws::Templates::Utils::Dependent

Included in:
Artifact, Parametrized, Parametrized::Nested
Defined in:
lib/aws/templates/utils/dependent.rb

Overview

Dependency node mixin

Introduces methods needed to track dependencies of an object. The object needs to implement options method and root method.

Instance Method Summary collapse

Instance Method Details

#depends_on(*depends) ⇒ Object

Introduce dependencies manually

Dependencies are calculated from “options” recursive structure by traversal and location of all dependencies automatically. If some dependency is not logical/parametrical but purely chronological, it can be introduced into the dependency list with this method.



20
21
22
23
24
25
26
27
# File 'lib/aws/templates/utils/dependent.rb', line 20

def depends_on(*depends)
  new_dependencies = depends.map { |obj| obj.dependency? ? obj.dependencies : Set[obj] }
                            .reduce(&:merge)

  new_dependencies.select! { |obj| obj.root == root } unless root.nil?
  dependencies.merge(new_dependencies)
  self
end