Class: ScoutApm::LayerConverters::FindLayerByType

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

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ FindLayerByType

Returns a new instance of FindLayerByType.



11
12
13
# File 'lib/scout_apm/layer_converters/find_layer_by_type.rb', line 11

def initialize(request)
  @request = request
end

Instance Method Details

#call(layer_types) ⇒ Object



31
32
33
34
35
# File 'lib/scout_apm/layer_converters/find_layer_by_type.rb', line 31

def call(layer_types)
  walker = DepthFirstWalker.new(@request.root_layer)
  walker.on {|l| return l if layer_types.include?(l.type) }
  walker.walk
end

#controllerObject



19
20
21
# File 'lib/scout_apm/layer_converters/find_layer_by_type.rb', line 19

def controller
  @controller ||= call(["Controller"])
end

#jobObject



23
24
25
# File 'lib/scout_apm/layer_converters/find_layer_by_type.rb', line 23

def job
  @job ||= call(["Job"])
end

#queueObject



27
28
29
# File 'lib/scout_apm/layer_converters/find_layer_by_type.rb', line 27

def queue
  @queue ||= call(["Queue"])
end

#scopeObject



15
16
17
# File 'lib/scout_apm/layer_converters/find_layer_by_type.rb', line 15

def scope
  @scope ||= call(["Controller", "Job"])
end