Module: TestProf::EventProf::Monitor

Defined in:
lib/test_prof/event_prof/monitor.rb

Overview

Wrap methods with instrumentation

Class Method Summary collapse

Class Method Details

.call(mod, event, *mids) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/test_prof/event_prof/monitor.rb', line 8

def call(mod, event, *mids)
  patch = Module.new do
    mids.each do |mid|
      module_eval <<~SRC, __FILE__, __LINE__ + 1
        def #{mid}(*)
          TestProf::EventProf.instrumenter.instrument(
            '#{event}'
          ) { super }
        end
      SRC
    end
  end

  mod.prepend(patch)
end