lib/active_support/duration.rb in activesupport-2.0.5 vs lib/active_support/duration.rb in activesupport-2.1.0

- old
+ new

@@ -49,18 +49,18 @@ other.is_a?(Duration) rescue super end # Calculates a new Time or Date that is as far in the future # as this Duration represents. - def since(time = ::Time.now) + def since(time = ::Time.current) sum(1, time) end alias :from_now :since # Calculates a new Time or Date that is as far in the past # as this Duration represents. - def ago(time = ::Time.now) + def ago(time = ::Time.current) sum(-1, time) end alias :until :ago def inspect #:nodoc: @@ -71,19 +71,19 @@ end.compact.to_sentence end protected - def sum(sign, time = ::Time.now) #:nodoc: + def sum(sign, time = ::Time.current) #:nodoc: parts.inject(time) do |t,(type,number)| if t.acts_like?(:time) || t.acts_like?(:date) if type == :seconds t.since(sign * number) else t.advance(type => sign * number) end else - raise ArgumentError, "expected a time or date, got #{time.inspect}" + raise ::ArgumentError, "expected a time or date, got #{time.inspect}" end end end private