Class: Fiona7::Builder::BatchWidgetWriter::WidgetGraph

Inherits:
Object
  • Object
show all
Includes:
TSort
Defined in:
lib/fiona7/builder/batch_widget_writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(nodes) ⇒ WidgetGraph

Returns a new instance of WidgetGraph.



14
15
16
17
18
19
20
21
22
23
# File 'lib/fiona7/builder/batch_widget_writer.rb', line 14

def initialize(nodes)
  @nodes = nodes
  @dependencies = {}

  @nodes.each do |node|
    @dependencies[node] = node.dependencies.map do |id|
      node = @nodes.find {|n| n.id.to_sym == id.to_sym }
    end.compact
  end
end

Instance Method Details

#tsort_each_child(node, &block) ⇒ Object



29
30
31
32
33
34
# File 'lib/fiona7/builder/batch_widget_writer.rb', line 29

def tsort_each_child(node, &block)
  if !@dependencies[node]
    raise Scrivito::ScrivitoError, "Broken widget dependency graph"
  end
  @dependencies[node].each(&block)
end

#tsort_each_node(&block) ⇒ Object



25
26
27
# File 'lib/fiona7/builder/batch_widget_writer.rb', line 25

def tsort_each_node(&block)
  @nodes.each(&block)
end