lib/ridgepole/migration_ext.rb in ridgepole-0.6.4.beta8 vs lib/ridgepole/migration_ext.rb in ridgepole-0.6.4.beta9

- old
+ new

@@ -4,10 +4,24 @@ module MigrationExt def self.prepended(klass) klass.class_eval do cattr_accessor :time_recorder cattr_accessor :disable_logging + + def self.record_time + result = nil + + begin + self.time_recorder = TimeRecorder.new + yield + result = self.time_recorder.result + ensure + self.time_recorder = nil + end + + result + end end end def write(text = '') logger = Ridgepole::Logger.instance @@ -22,23 +36,9 @@ when /\A--\s+(.+)\Z/ self.time_recorder.add_key($1) when /\A\s+->\s+(\d+\.\d+)s\Z/ self.time_recorder.add_value($1.to_f) end - end - - def self.record_time - result = nil - - begin - self.time_recorder = TimeRecorder.new - yield - result = self.time_recorder.result - ensure - self.time_recorder = nil - end - - result end class TimeRecorder attr_reader :result