Skip to content

Commit

Permalink
Explicitly delegate Chars#<=> to work around Kernel#<=> possibly igno…
Browse files Browse the repository at this point in the history
…ring method_missing
  • Loading branch information
jeremy committed Jun 11, 2010
1 parent 85cc1fa commit cfc9439
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions activesupport/lib/active_support/multibyte/chars.rb
Expand Up @@ -34,7 +34,6 @@ module Multibyte #:nodoc:
#
# ActiveSupport::Multibyte.proxy_class = CharsForUTF32
class Chars

attr_reader :wrapped_string
alias to_s wrapped_string
alias to_str wrapped_string
Expand All @@ -45,14 +44,16 @@ def initialize(string)
@wrapped_string = string
@wrapped_string.force_encoding(Encoding::UTF_8) unless @wrapped_string.frozen?
end

undef <=>
else
def initialize(string) #:nodoc:
@wrapped_string = string
end
end

def <=>(other)
@wrapped_string <=> other
end

# Forward all undefined methods to the wrapped string.
def method_missing(method, *args, &block)
if method.to_s =~ /!$/
Expand Down

0 comments on commit cfc9439

Please sign in to comment.