mirror of https://github.com/rails/rails
Merge pull request #17160 from lsylvester/duration-hash
define hash on duration
This commit is contained in:
commit
23ef52514e
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue