lib/active_support/duration.rb in activesupport-3.0.0.beta4 vs lib/active_support/duration.rb in activesupport-3.0.pre
- old
+ new
@@ -1,8 +1,7 @@
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:
@@ -34,13 +33,12 @@
def -@ #:nodoc:
Duration.new(-value, parts.map { |type,number| [type, -number] })
end
def is_a?(klass) #:nodoc:
- Duration == klass || value.is_a?(klass)
+ klass == Duration || super
end
- alias :kind_of? :is_a?
# 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)
if Duration === other
@@ -49,12 +47,10 @@
other == value
end
end
def self.===(other) #:nodoc:
- other.is_a?(Duration)
- rescue ::NoMethodError
- false
+ 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.current)