This project is archived and is in readonly mode.
Chars class doesn't proxy "include?"
-
Xavier Noria
Problem is
>> "foo".chars.handler.respond_to?("include?") => true >> "foo".chars.handler => ActiveSupport::Multibyte::Handlers::UTF8Handlerthat is a Class object, which responds to "include?" because of Module#include?. That method expects an argument and it is being passes the proxied string and the argument itself.
-
Xavier Noria
Let me rephrase the comment above.
The proxy asks first the handler if it responds to the method, if it does not sends it to the proxied string.
Since the handler responds to "include?" it gets called on it, but that method is Module#include?. So indeed there's a mismatch in the interface, and additionallly that's the explanation for the way it breaks.
-
jdwyah
Yep, I agree that this is the problem. What do you think, is it appropriate to just add an include? method to Chars (or UTF8Handler)? or is there a cleaner fix?
-
Yaroslav Markin
I think #include? should be defined for Multibyte..
-
Manfred Stienstra
The correct fix would be to add an include? method to the handler.
-
Craig Davey
- Tag set to 2.0-stable, activesupport, bug
This patch adds an include? method to ActiveSupport::Multibyte::Handlers::UTF8Handler so that string.chars.include? acts the same as string.include?
-
Manfred Stienstra
- Tag changed from 2.0-stable, activesupport, bug to 2.0-stable, activesupport, bug
This seems to be fixed, can someone close this ticket?
-
Yaroslav Markin
- Tag changed from 2.0-stable, activesupport, bug to 2.0-stable, activesupport, bug
- Assigned user set to Pratik
