Class: ScoutApm::LayerDepthFirstWalker
- Inherits:
-
Object
- Object
- ScoutApm::LayerDepthFirstWalker
- Defined in:
- lib/scout_apm/layer_converter.rb
Instance Attribute Summary collapse
-
#root_layer ⇒ Object
readonly
Returns the value of attribute root_layer.
Instance Method Summary collapse
- #after(&block) ⇒ Object
- #before(&block) ⇒ Object
-
#initialize(root_layer) ⇒ LayerDepthFirstWalker
constructor
A new instance of LayerDepthFirstWalker.
- #walk(layer = root_layer, &block) ⇒ Object
Constructor Details
#initialize(root_layer) ⇒ LayerDepthFirstWalker
Returns a new instance of LayerDepthFirstWalker.
183 184 185 |
# File 'lib/scout_apm/layer_converter.rb', line 183 def initialize(root_layer) @root_layer = root_layer end |
Instance Attribute Details
#root_layer ⇒ Object (readonly)
Returns the value of attribute root_layer.
181 182 183 |
# File 'lib/scout_apm/layer_converter.rb', line 181 def root_layer @root_layer end |
Instance Method Details
#after(&block) ⇒ Object
191 192 193 |
# File 'lib/scout_apm/layer_converter.rb', line 191 def after(&block) @after_block = block end |
#before(&block) ⇒ Object
187 188 189 |
# File 'lib/scout_apm/layer_converter.rb', line 187 def before(&block) @before_block = block end |
#walk(layer = root_layer, &block) ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/scout_apm/layer_converter.rb', line 195 def walk(layer=root_layer, &block) # Need to run this for the root layer the first time through. if layer == root_layer @before_block.call(layer) if @before_block yield layer @after_block.call(layer) if @after_block end layer.children.each do |child| @before_block.call(child) if @before_block yield child walk(child, &block) @after_block.call(child) if @after_block end nil end |