89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/tick.rb', line 89
def tick(method_name, options = {})
if Tick.enabled
alias_method "#{method_name}_without_tick", method_name
define_method method_name do
result = nil
if Tick.enabled sec = Benchmark.realtime { result = self.send("#{method_name}_without_tick") }
desc = nil
if options[:message].kind_of?(Proc)
desc = options[:message].call(self.class.name, method_name)
else
desc = options[:message] || Tick.desc_message.call(self.class.name, method_name)
end
time = Tick.time_message.call(sec)
_log_benchmark(desc, time)
else
result = self.send("#{method_name}_without_tick")
end
result
end
end
end
|