Method: HyperTrace.instrument_method

Defined in:
lib/hyper_trace/hyper_trace.rb

.instrument_method(method, config) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/hyper_trace/hyper_trace.rb', line 145

def instrument_method(method, config)
  if config.instrument_class?
    config.klass.class_eval do
      class << self
        alias_method "__hyper_trace_pre_#{method}", method unless method_defined? "__pre_hyper_trace_#{method}"
      end
    end
    add_hyper_trace_method(method, config)
  else
    unless config.klass.method_defined? "__pre_hyper_trace_#{method}"
      config.klass.class_eval do
        alias_method "__hyper_trace_pre_#{method}", method
      end
    end
  end
  add_hyper_trace_method(method, config)
end