Class: ScoutApm::LayerConverters::ConverterBase

Inherits:
Object
  • Object
show all
Defined in:
lib/scout_apm/layer_converters/converter_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ ConverterBase

Returns a new instance of ConverterBase.



8
9
10
11
12
# File 'lib/scout_apm/layer_converters/converter_base.rb', line 8

def initialize(request)
  @request = request
  @root_layer = request.root_layer
  @walker = DepthFirstWalker.new(root_layer)
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



5
6
7
# File 'lib/scout_apm/layer_converters/converter_base.rb', line 5

def request
  @request
end

#root_layerObject (readonly)

Returns the value of attribute root_layer.



6
7
8
# File 'lib/scout_apm/layer_converters/converter_base.rb', line 6

def root_layer
  @root_layer
end

#walkerObject (readonly)

Returns the value of attribute walker.



4
5
6
# File 'lib/scout_apm/layer_converters/converter_base.rb', line 4

def walker
  @walker
end

Instance Method Details

#find_first_layer_of_type(layer_type) ⇒ Object



25
26
27
28
29
# File 'lib/scout_apm/layer_converters/converter_base.rb', line 25

def find_first_layer_of_type(layer_type)
  walker.walk do |layer|
    return layer if layer.type == layer_type
  end
end

#scope_layerObject

Scope is determined by the first Controller we hit. Most of the time there will only be 1 anyway. But if you have a controller that calls another controller method, we may pick that up:

def update
  show
  render :update
end


21
22
23
# File 'lib/scout_apm/layer_converters/converter_base.rb', line 21

def scope_layer
  @scope_layer ||= find_first_layer_of_type("Controller") || find_first_layer_of_type("Job")
end