1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

define hash on duration

This commit is contained in:
lsylvester 2014-10-03 19:53:54 +10:00
parent de50a91daa
commit 6c57c78671
2 changed files with 8 additions and 0 deletions

View file

@ -63,6 +63,10 @@ module ActiveSupport
Duration === other && other.value.eql?(value) Duration === other && other.value.eql?(value)
end end
def hash
@value.hash
end
def self.===(other) #:nodoc: def self.===(other) #:nodoc:
other.is_a?(Duration) other.is_a?(Duration)
rescue ::NoMethodError rescue ::NoMethodError

View file

@ -196,4 +196,8 @@ class DurationTest < ActiveSupport::TestCase
assert_respond_to 1.day, :since assert_respond_to 1.day, :since
assert_respond_to 1.day, :zero? assert_respond_to 1.day, :zero?
end end
def test_hash
assert_equal 1.minute.hash, 60.seconds.hash
end
end end