4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/overnight/mixins/method_timer.rb', line 4
def self.included(base_class)
methods = base_class.instance_methods(false) + base_class.private_instance_methods(false)
base_class.class_eval do
methods.each do |method_name|
old_method = instance_method(method_name)
define_method(method_name) do |*args, &block|
logged_name = Overnight::MethodTimer.timer_name(base_class.name + "_" + method_name.to_s)
OvernightService.start_timer(logged_name)
result = old_method.bind(self).call(*args, &block)
OvernightService.stop_timer(logged_name)
return result
end
end
end
end
|