Class: Trailblazer::Developer::Debugger::Node

Inherits:
Struct
  • Object
show all
Defined in:
lib/trailblazer/developer/debugger.rb

Overview

The Node is an abstraction between Trace::Node and the actual rendering layer (why?)

TODO: class, “type”, which track, return signal, etc

Defined Under Namespace

Classes: DeprecatedCapturedNode

Class Method Summary collapse

Class Method Details

.build(trace_nodes, node_options: {}, normalizer: Debugger::Normalizer::PIPELINES.last, **options_for_nodes) ⇒ Debugger::Node

we always key options for specific nodes by Stack::Captured::Input, so we don’t confuse activities if they were called multiple times.

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/trailblazer/developer/debugger.rb', line 29

def self.build(trace_nodes, node_options: {}, normalizer: Debugger::Normalizer::PIPELINES.last, **options_for_nodes)
  # DISCUSS: this might change if we introduce a new Node type for Trace.
  _debugger_nodes = trace_nodes.collect do |trace_node|
    # it's possible to pass per-node options, like {label: "Yo!"} via {:node_options[<snapshot_before>]}
    options_from_user  = node_options[trace_node] || {}

    options_from_trace_node = trace_node
      .to_h # :level, :snapshot_before, :snapshot_after
      .merge(
        id:           trace_node.object_id,
        trace_node:   trace_node,
        activity:     trace_node.snapshot_before.activity,
        task:         trace_node.task,
        captured_node: DeprecatedCapturedNode, # TODO: remove once macro is 2.2
      )

    options_for_debugger_node, _ = normalizer.(
      {
        **options_from_trace_node,
        **options_from_user
      },
      []
    )

    # these attributes are not changing with the presentation
    Debugger::Node.new(**options_for_debugger_node).freeze
  end
end