Class: ScoutApm::LayerConverters::ConverterBase
- Inherits:
-
Object
- Object
- ScoutApm::LayerConverters::ConverterBase
- Defined in:
- lib/scout_apm/layer_converters/converter_base.rb
Direct Known Subclasses
ErrorConverter, JobConverter, MetricConverter, RequestQueueTimeConverter, SlowJobConverter, SlowRequestConverter
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#root_layer ⇒ Object
readonly
Returns the value of attribute root_layer.
-
#walker ⇒ Object
readonly
Returns the value of attribute walker.
Instance Method Summary collapse
- #find_first_layer_of_type(layer_type) ⇒ Object
-
#initialize(request) ⇒ ConverterBase
constructor
A new instance of ConverterBase.
-
#scope_layer ⇒ Object
Scope is determined by the first Controller we hit.
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
#request ⇒ Object (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_layer ⇒ Object (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 |
#walker ⇒ Object (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_layer ⇒ Object
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 |