From f9767514cbdd6ef38aa62f084059776d75ed6962 Mon Sep 17 00:00:00 2001 From: lsylvester Date: Wed, 20 Aug 2014 04:56:54 -0200 Subject: add implementation of respond_to? for ActiveSupport::Duration --- activesupport/lib/active_support/duration.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/duration.rb') diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb index 1a6c02a39b..a54494bc65 100644 --- a/activesupport/lib/active_support/duration.rb +++ b/activesupport/lib/active_support/duration.rb @@ -7,7 +7,7 @@ module ActiveSupport # Time#advance, respectively. It mainly supports the methods on Numeric. # # 1.month.ago # equivalent to Time.now.advance(months: -1) - class Duration < ProxyObject + class Duration attr_accessor :value, :parts def initialize(value, parts) #:nodoc: @@ -53,6 +53,10 @@ module ActiveSupport end end + def to_s + @value.to_s + end + def eql?(other) other.is_a?(Duration) && self == other end @@ -89,6 +93,10 @@ module ActiveSupport to_i end + def respond_to_missing?(method, include_private=false) #:nodoc + @value.respond_to?(method, include_private) + end + protected def sum(sign, time = ::Time.current) #:nodoc: -- cgit v1.2.3