From 9ae511f55047b2380224ad993a7d0ed97dbcf944 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 12 Jan 2017 10:02:16 +0000 Subject: Add duration constructors for use in Numeric extensions The Numeric extensions like 1.day, 1.month, etc. shouldn't know how the internals of ActiveSupport::Duration works. --- activesupport/lib/active_support/core_ext/integer/time.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/core_ext/integer') diff --git a/activesupport/lib/active_support/core_ext/integer/time.rb b/activesupport/lib/active_support/core_ext/integer/time.rb index 66ac3ca1b4..74baae3639 100644 --- a/activesupport/lib/active_support/core_ext/integer/time.rb +++ b/activesupport/lib/active_support/core_ext/integer/time.rb @@ -18,12 +18,12 @@ class Integer # # equivalent to Time.now.advance(months: 4, years: 5) # (4.months + 5.years).from_now def months - ActiveSupport::Duration.new(self * ActiveSupport::Duration::PARTS_IN_SECONDS[:months].to_i, [[:months, self]]) + ActiveSupport::Duration.months(self) end alias :month :months def years - ActiveSupport::Duration.new(self * ActiveSupport::Duration::PARTS_IN_SECONDS[:years].to_i, [[:years, self]]) + ActiveSupport::Duration.years(self) end alias :year :years end -- cgit v1.2.3