aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-05-31 14:54:17 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-05-31 14:55:02 -0700
commit4e4bcb4c6b08ed392cd5576dcfc252ef574a1b88 (patch)
tree3ee0296a3dfbdba16f2e113453a58207d52830db /activesupport/lib
parent2243ffd1ffe3a129af20a33e72574f7ee4534730 (diff)
downloadrails-4e4bcb4c6b08ed392cd5576dcfc252ef574a1b88.tar.gz
rails-4e4bcb4c6b08ed392cd5576dcfc252ef574a1b88.tar.bz2
rails-4e4bcb4c6b08ed392cd5576dcfc252ef574a1b88.zip
Ruby 1.8.7 compat: TimeWithZone# and Chars#respond_to? pass along the include_private argument
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/multibyte/chars.rb12
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb8
2 files changed, 11 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb
index ee716de39e..185d03020c 100644
--- a/activesupport/lib/active_support/multibyte/chars.rb
+++ b/activesupport/lib/active_support/multibyte/chars.rb
@@ -40,13 +40,15 @@ module ActiveSupport::Multibyte #:nodoc:
# core dumps. Don't go there.
@string
end
-
+
# Make duck-typing with String possible
- def respond_to?(method)
- super || @string.respond_to?(method) || handler.respond_to?(method) ||
- (method.to_s =~ /(.*)!/ && handler.respond_to?($1)) || false
+ def respond_to?(method, include_priv = false)
+ super || @string.respond_to?(method, include_priv) ||
+ handler.respond_to?(method, include_priv) ||
+ (method.to_s =~ /(.*)!/ && handler.respond_to?($1, include_priv)) ||
+ false
end
-
+
# Create a new Chars instance.
def initialize(str)
@string = str.respond_to?(:string) ? str.string : str
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index ece95eeae9..bfc5b16039 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -248,14 +248,14 @@ module ActiveSupport
def marshal_load(variables)
initialize(variables[0], ::Time.send!(:get_zone, variables[1]), variables[2])
end
-
+
# Ensure proxy class responds to all methods that underlying time instance responds to.
- def respond_to?(sym)
+ def respond_to?(sym, include_priv = false)
# consistently respond false to acts_like?(:date), regardless of whether #time is a Time or DateTime
return false if sym.to_s == 'acts_like_date?'
- super || time.respond_to?(sym)
+ super || time.respond_to?(sym, include_priv)
end
-
+
# Send the missing method to +time+ instance, and wrap result in a new TimeWithZone with the existing +time_zone+.
def method_missing(sym, *args, &block)
result = time.__send__(sym, *args, &block)