module TestProf::EventProf::Monitor

Wrap methods with instrumentation

Public Class Methods

call(mod, event, *mids, guard: nil, top_level: false) click to toggle source
Calls superclass method
# 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