lib/ruby-progressbar/time.rb in ruby-progressbar-1.6.1 vs lib/ruby-progressbar/time.rb in ruby-progressbar-1.7.0

- old
+ new

@@ -1,22 +1,25 @@ -class ProgressBar - class Time - def self.now(time = ::Time) - @@time = time +class ProgressBar +class Time + def self.now(time = ::Time) + @time = time - @@time.send unmocked_time_method - end + @time.send unmocked_time_method + end - private - def self.unmocked_time_method - time_mocking_library_methods.find { |method| @@time.respond_to? method } - end + def self.unmocked_time_method + @unmocked_time_method ||= begin + time_mocking_library_methods.find do |method| + @time.respond_to? method + end + end + end - def self.time_mocking_library_methods - [ - :now_without_mock_time, # Timecop - :now_without_delorean, # Delorean - :now # Actual - ] - end + def self.time_mocking_library_methods + [ + :now_without_mock_time, # Timecop + :now_without_delorean, # Delorean + :now # Actual + ] end +end end