aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2007-01-15 17:13:45 +0000
committerJamis Buck <jamis@37signals.com>2007-01-15 17:13:45 +0000
commit5314960d8b27957c01ad1a6cf3ef5a5624cef713 (patch)
tree588717e44debf51d702972ae0871c77e53428685 /activesupport
parentf28eef9a272fd9280416fd8c0984f616ffe102fe (diff)
downloadrails-5314960d8b27957c01ad1a6cf3ef5a5624cef713.tar.gz
rails-5314960d8b27957c01ad1a6cf3ef5a5624cef713.tar.bz2
rails-5314960d8b27957c01ad1a6cf3ef5a5624cef713.zip
change Duration to use the new Object#acts_like? helper to do duck typing
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5952 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/duration.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb
index 3696697224..8e518cb00b 100644
--- a/activesupport/lib/active_support/duration.rb
+++ b/activesupport/lib/active_support/duration.rb
@@ -65,13 +65,13 @@ module ActiveSupport
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