Module: TestProf::EventProf::Monitor
- Defined in:
- lib/test_prof/event_prof/monitor.rb
Overview
Wrap methods with instrumentation
Defined Under Namespace
Classes: BaseTracker, TopLevelTracker
Class Method Summary collapse
Class Method Details
.call(mod, event, *mids, guard: nil, top_level: false) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/test_prof/event_prof/monitor.rb', line 46 def call(mod, event, *mids, guard: nil, top_level: false) tracker = top_level ? TopLevelTracker.new(event) : BaseTracker.new(event) patch = Module.new do mids.each do |mid| define_method(mid) do |*args, &block| next super(*args, &block) unless guard.nil? || instance_exec(*args, &guard) tracker.track { super(*args, &block) } end end end mod.prepend(patch) end |