Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change Duration to use the new Object#acts_like? helper to do duck ty…

…ping

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5952 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 5314960d8b27957c01ad1a6cf3ef5a5624cef713 1 parent f28eef9
@jamis jamis authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 activesupport/lib/active_support/duration.rb
View
4 activesupport/lib/active_support/duration.rb
@@ -65,13 +65,13 @@ def inspect #:nodoc:
def sum(sign, time = ::Time.now) #:nodoc:
parts.inject(time) do |t,(type,number)|
- if t.respond_to?(:sec) # quacks like a Time
+ if t.acts_like?(:time)
if type == :seconds
t + (sign * number)
else
t.advance(type => sign * number)
end
- elsif t.respond_to?(:day) # quacks like a Date
+ elsif t.acts_like?(:date)
raise ArgumentError, "Adding seconds to a Date does not make sense" if type == :seconds
t.advance(type => sign * number)
else
Please sign in to comment.
Something went wrong with that request. Please try again.