Class: Debug

Inherits:
Object show all
Defined in:
lib/RubyExt/Debug.rb

Class Method Summary collapse

Class Method Details

.trace_methods(klass) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/RubyExt/Debug.rb', line 4

def trace_methods klass
	klass.instance_methods(false).each do |m|
		klass.class_eval do		
			alias_method :"old_#{m}", m		
			define_method m.to_sym do |*args|
				begin
					time = Time.now
					p [m.to_sym, :start]
					result = send :"old_#{m}", *args							
				ensure
					p [m.to_sym, :end, time - Time.now]
				end
				return result
			end
		end
	end
end