Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/rack/bug/speedtracer/duck-puncher.rb
Instance Method Summary collapse
- #build_tracing_wrappers(context, *methods) ⇒ Object
- #trace_class_methods(*methods_names) ⇒ Object
- #trace_methods(*methods) ⇒ Object
Instance Method Details
#build_tracing_wrappers(context, *methods) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rack/bug/speedtracer/duck-puncher.rb', line 64 def build_tracing_wrappers(context, *methods) @traced ||= {} Rack::Bug::SpeedTracer::safe_method_names(self, methods).each do |method_name, old_method| next if @traced.has_key?(method_name) @traced[method_name] = true alias_method old_method, method_name self.class_eval <<-EOC, __FILE__, __LINE__ def #{method_name}(*args, &block) trace_run("#{context}", caller(0)[0], args) do #{old_method}(*args, &block) end end EOC end end |
#trace_class_methods(*methods_names) ⇒ Object
56 57 58 |
# File 'lib/rack/bug/speedtracer/duck-puncher.rb', line 56 def trace_class_methods(*methods_names) (class << self; self; end).build_tracing_wrappers('#{self.name}::', *methods_names) end |
#trace_methods(*methods) ⇒ Object
60 61 62 |
# File 'lib/rack/bug/speedtracer/duck-puncher.rb', line 60 def trace_methods(*methods) build_tracing_wrappers('#{self.class.name}#', *methods) end |