Class: Trailblazer::Developer::Trace::Stack

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

Overview

Mutable/stateful per design. We want a (global) stack!

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStack

Returns a new instance of Stack.



134
135
136
137
# File 'lib/trailblazer/developer/trace.rb', line 134

def initialize
  @nested  = Level.new
  @stack   = [ @nested ]
end

Instance Attribute Details

#topObject (readonly)

Returns the value of attribute top.



132
133
134
# File 'lib/trailblazer/developer/trace.rb', line 132

def top
  @top
end

Instance Method Details

#<<(entity) ⇒ Object



148
149
150
151
152
# File 'lib/trailblazer/developer/trace.rb', line 148

def <<(entity)
  @top = entity

  current << entity
end

#indent!Object



139
140
141
142
# File 'lib/trailblazer/developer/trace.rb', line 139

def indent!
  current << indented = Level.new
  @stack << indented
end

#to_aObject



154
155
156
# File 'lib/trailblazer/developer/trace.rb', line 154

def to_a
  @nested
end

#unindent!Object



144
145
146
# File 'lib/trailblazer/developer/trace.rb', line 144

def unindent!
  @stack.pop
end