Module: Thredded::DatabaseSeeder::LogTime

Included in:
Thredded::DatabaseSeeder, BaseSeedData
Defined in:
lib/thredded/database_seeder.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


15
16
17
# File 'lib/thredded/database_seeder.rb', line 15

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#log_timeObject


19
20
21
22
23
24
# File 'lib/thredded/database_seeder.rb', line 19

def log_time
  start = Time.now.to_f
  result = yield
  print_time_diff start
  result
end

26
27
28
# File 'lib/thredded/database_seeder.rb', line 26

def print_time_diff(from, to = Time.now.to_f)
  log " [#{format('%.2f', to - from)}s]\n"
end