diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-10-03 16:52:25 +0200 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-10-03 16:52:25 +0200 |
commit | 23ef52514edbc1ded7e1a23217a87a5f10bc54b7 (patch) | |
tree | 1acdaf78dc69bc92c3843c353708e3f3f409203a /activesupport | |
parent | de50a91daad90bf2a0e6bece60a1c2211ade4682 (diff) | |
parent | 6c57c78671ef49922643361cfb0a9287986be904 (diff) | |
download | rails-23ef52514edbc1ded7e1a23217a87a5f10bc54b7.tar.gz rails-23ef52514edbc1ded7e1a23217a87a5f10bc54b7.tar.bz2 rails-23ef52514edbc1ded7e1a23217a87a5f10bc54b7.zip |
Merge pull request #17160 from lsylvester/duration-hash
define hash on duration
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/duration.rb | 4 | ||||
-rw-r--r-- | activesupport/test/core_ext/duration_test.rb | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb index e861a17426..584fc1e1c5 100644 --- a/activesupport/lib/active_support/duration.rb +++ b/activesupport/lib/active_support/duration.rb @@ -63,6 +63,10 @@ module ActiveSupport Duration === other && other.value.eql?(value) end + def hash + @value.hash + end + def self.===(other) #:nodoc: other.is_a?(Duration) rescue ::NoMethodError diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index f4d504914e..5a2af7f943 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -196,4 +196,8 @@ class DurationTest < ActiveSupport::TestCase assert_respond_to 1.day, :since assert_respond_to 1.day, :zero? end + + def test_hash + assert_equal 1.minute.hash, 60.seconds.hash + end end |