Class: Callstacking::Rails::Loader
- Inherits:
-
Object
- Object
- Callstacking::Rails::Loader
- Defined in:
- lib/callstacking/rails/loader.rb
Instance Attribute Summary collapse
-
#excluded ⇒ Object
Returns the value of attribute excluded.
-
#instrumenter ⇒ Object
Returns the value of attribute instrumenter.
-
#klasses ⇒ Object
Returns the value of attribute klasses.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
-
#initialize(instrumenter, excluded: []) ⇒ Loader
constructor
A new instance of Loader.
- #on_load ⇒ Object
- #preloaded_klasses ⇒ Object
- #reset! ⇒ Object
Constructor Details
#initialize(instrumenter, excluded: []) ⇒ Loader
Returns a new instance of Loader.
8 9 10 11 12 13 14 15 |
# File 'lib/callstacking/rails/loader.rb', line 8 def initialize(instrumenter, excluded: []) @excluded = excluded @instrumenter = instrumenter @klasses = Set.new @settings = Callstacking::Rails::Settings.new preloaded_klasses end |
Instance Attribute Details
#excluded ⇒ Object
Returns the value of attribute excluded.
7 8 9 |
# File 'lib/callstacking/rails/loader.rb', line 7 def excluded @excluded end |
#instrumenter ⇒ Object
Returns the value of attribute instrumenter.
7 8 9 |
# File 'lib/callstacking/rails/loader.rb', line 7 def instrumenter @instrumenter end |
#klasses ⇒ Object
Returns the value of attribute klasses.
7 8 9 |
# File 'lib/callstacking/rails/loader.rb', line 7 def klasses @klasses end |
#settings ⇒ Object
Returns the value of attribute settings.
7 8 9 |
# File 'lib/callstacking/rails/loader.rb', line 7 def settings @settings end |
Instance Method Details
#on_load ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/callstacking/rails/loader.rb', line 21 def on_load trace = TracePoint.new(:end) do |tp| klass = tp.self path = tp.path filter_klass(klass, path) end trace.enable end |
#preloaded_klasses ⇒ Object
17 18 19 |
# File 'lib/callstacking/rails/loader.rb', line 17 def preloaded_klasses ObjectSpace.each_object(Module){|ob| filter_klass(ob, (Object.const_source_location(ob.to_s)&.first rescue nil))} end |
#reset! ⇒ Object
32 33 34 35 |
# File 'lib/callstacking/rails/loader.rb', line 32 def reset! instrumenter.instrument_method(ActionView::PartialRenderer, :render, application_level: false) instrumenter.instrument_method(ActionView::TemplateRenderer, :render, application_level: false) end |