diff options
author | lsylvester <lachlan.sylvester@hypothetical.com.au> | 2014-08-20 04:56:54 -0200 |
---|---|---|
committer | lsylvester <lachlan.sylvester@hypothetical.com.au> | 2014-09-15 13:59:19 +1000 |
commit | f9767514cbdd6ef38aa62f084059776d75ed6962 (patch) | |
tree | 25d622d57c2c02921e0ef527730adc4c6d230ba6 /activesupport/lib/active_support | |
parent | a3a8a691b2a826f19d71780b1ba9ffac15eb4f89 (diff) | |
download | rails-f9767514cbdd6ef38aa62f084059776d75ed6962.tar.gz rails-f9767514cbdd6ef38aa62f084059776d75ed6962.tar.bz2 rails-f9767514cbdd6ef38aa62f084059776d75ed6962.zip |
add implementation of respond_to? for ActiveSupport::Duration
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/duration.rb | 10 |
1 files changed, 9 insertions, 1 deletions
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: |