diff options
author | Andrew White <andrew.white@unboxed.co> | 2017-01-12 10:02:16 +0000 |
---|---|---|
committer | Andrew White <andrew.white@unboxed.co> | 2017-01-12 10:05:16 +0000 |
commit | 9ae511f55047b2380224ad993a7d0ed97dbcf944 (patch) | |
tree | f381ee6e343edc72cc89036928737383fde690e7 /activesupport/lib/active_support/core_ext/integer | |
parent | 2a5ae2b714046d3f7eb1219eb366cf84c1cf9bb5 (diff) | |
download | rails-9ae511f55047b2380224ad993a7d0ed97dbcf944.tar.gz rails-9ae511f55047b2380224ad993a7d0ed97dbcf944.tar.bz2 rails-9ae511f55047b2380224ad993a7d0ed97dbcf944.zip |
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.
Diffstat (limited to 'activesupport/lib/active_support/core_ext/integer')
-rw-r--r-- | activesupport/lib/active_support/core_ext/integer/time.rb | 4 |
1 files changed, 2 insertions, 2 deletions
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 |