Class: Vissen::Parameterized::Graph

Inherits:
Object
  • Object
show all
Defined in:
lib/vissen/parameterized/graph.rb

Overview

The graph implements a mechanism for updating and untainting a set of interconnected paramaeterized objects.

Instance Method Summary collapse

Constructor Details

#initialize(end_nodes, scope: GlobalScope.instance) ⇒ Graph

Returns a new instance of Graph.

Parameters:

  • end_nodes (Array<Parameterized>)

    the top level parameterized objects.

  • scope (Scope) (defaults to: GlobalScope.instance)

    the scope in which the graph (and the end nodes) exists.

Raises:

  • (ScopeError)

    if any of the end nodes are not included in the scope.



15
16
17
18
19
20
21
22
23
# File 'lib/vissen/parameterized/graph.rb', line 15

def initialize(end_nodes, scope: GlobalScope.instance)
  end_nodes.each do |node|
    raise ScopeError unless scope.include? node
  end

  @end_nodes = end_nodes

  freeze
end

Instance Method Details

#update!Object

Updates the entire graph.



26
27
28
29
30
31
# File 'lib/vissen/parameterized/graph.rb', line 26

def update!
  @end_nodes.each(&:tainted?)
  @end_nodes.each(&:untaint!)

  @end_nodes.each { |node| yield node.value } if block_given?
end