lib/active_support/multibyte/chars.rb in activesupport-1.4.4 vs lib/active_support/multibyte/chars.rb in activesupport-2.0.0
- old
+ new
@@ -39,9 +39,15 @@
# Using any other ways of overriding the String itself will lead you all the way from infinite loops to
# 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
+ end
+
# Create a new Chars instance.
def initialize(str)
@string = str.respond_to?(:string) ? str.string : str
end