From 428d1f67dab05b84330c7fc66bff0202aee91bd8 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 28 May 2007 23:33:54 +0000 Subject: Multibyte strings respond_to the String methods they proxy so they can be duck-typed. Closes #6549. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6882 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/multibyte/chars.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index 901815092d..65114415eb 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -41,6 +41,12 @@ module ActiveSupport::Multibyte #:nodoc: @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 -- cgit v1.2.3