aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-17 16:15:25 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-09-17 16:15:25 -0300
commitacda46d08181cb39d9adf56f5f983dc0ffaaf96f (patch)
treeddc361a9466d37f12ecb2392c97f806ec3a50585 /activesupport/lib
parent84087966e84a9875fdf707193f376ffea8c80610 (diff)
parent369a107c8e30a15d03cb2e85242bc604fe7a02a3 (diff)
downloadrails-acda46d08181cb39d9adf56f5f983dc0ffaaf96f.tar.gz
rails-acda46d08181cb39d9adf56f5f983dc0ffaaf96f.tar.bz2
rails-acda46d08181cb39d9adf56f5f983dc0ffaaf96f.zip
Merge pull request #11794 from yoazt/duration-eql
Added method `#eql?` to `ActiveSupport::Duration`, in addition to `#==`. Conflicts: activesupport/CHANGELOG.md activesupport/lib/active_support/duration.rb activesupport/test/core_ext/duration_test.rb
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/duration.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb
index a54494bc65..e861a17426 100644
--- a/activesupport/lib/active_support/duration.rb
+++ b/activesupport/lib/active_support/duration.rb
@@ -57,8 +57,10 @@ module ActiveSupport
@value.to_s
end
+ # Returns +true+ if +other+ is also a Duration instance, which has the
+ # same parts as this one.
def eql?(other)
- other.is_a?(Duration) && self == other
+ Duration === other && other.value.eql?(value)
end
def self.===(other) #:nodoc: