Class: Trailblazer::Developer::Debugger::Trace

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

Overview

Interface for data (nodes, versions, etc) between tracing code and presentation layer. We have no concept of Stack here anymore. Nodes and arbitrary objects such as “versions”. Debugger::Trace interface abstracts away the fact we have two snapshots. Here, we only have a node per task.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes:, variable_versions:) ⇒ Trace

Returns a new instance of Trace.



83
84
85
# File 'lib/trailblazer/developer/debugger.rb', line 83

def initialize(nodes:, variable_versions:)
  @options = {nodes: nodes, variable_versions: variable_versions}
end

Class Method Details

.build(stack, trace_nodes, **options_for_debugger_nodes) ⇒ Object

Called in Trace::Present. Design note: goal here is to have as little computation as possible.



74
75
76
77
78
79
80
81
# File 'lib/trailblazer/developer/debugger.rb', line 74

def self.build(stack, trace_nodes, **options_for_debugger_nodes)
  nodes = Debugger::Node.build(
    trace_nodes,
    **options_for_debugger_nodes,
  )

  new(nodes: nodes, variable_versions: stack.variable_versions) # after this, the concept of "Stack" doesn't exist anymore.
end

Instance Method Details

#to_aObject



91
92
93
# File 'lib/trailblazer/developer/debugger.rb', line 91

def to_a
  to_h[:nodes].to_a
end

#to_hObject



87
88
89
# File 'lib/trailblazer/developer/debugger.rb', line 87

def to_h
  @options
end