Module: Ridgepole::MigrationExt
- Included in:
- ActiveRecord::Migration
- Defined in:
- lib/ridgepole/migration_ext.rb
Defined Under Namespace
Classes: TimeRecorder
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.prepended(klass) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ridgepole/migration_ext.rb', line 7 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 = time_recorder.result ensure self.time_recorder = nil end result end end end |
Instance Method Details
#parse_text(text) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ridgepole/migration_ext.rb', line 34 def parse_text(text) return unless time_recorder case text when /\A--\s+(.+)\Z/ time_recorder.add_key(Regexp.last_match(1)) when /\A\s+->\s+(\d+\.\d+)s\Z/ time_recorder.add_value(Regexp.last_match(1).to_f) end end |