lib/active_support/duration.rb in activesupport-2.3.18 vs lib/active_support/duration.rb in activesupport-3.0.0.beta

- old
+ new

@@ -1,6 +1,8 @@ require 'active_support/basic_object' +require 'active_support/core_ext/array/conversions' +require 'active_support/core_ext/object/acts_like' module ActiveSupport # Provides accurate date and time measurements using Date#advance and # Time#advance, respectively. It mainly supports the methods on Numeric, # such as in this example: @@ -32,11 +34,11 @@ def -@ #:nodoc: Duration.new(-value, parts.map { |type,number| [type, -number] }) end def is_a?(klass) #:nodoc: - klass == Duration || super + Duration == klass || value.is_a?(klass) end # Returns true if <tt>other</tt> is also a Duration instance with the # same <tt>value</tt>, or if <tt>other == value</tt>. def ==(other) @@ -46,10 +48,12 @@ other == value end end def self.===(other) #:nodoc: - other.is_a?(Duration) rescue super + other.is_a?(Duration) + rescue ::NoMethodError + false end # Calculates a new Time or Date that is as far in the future # as this Duration represents. def since(time = ::Time.current)