vendor/rails/activesupport/lib/active_support/multibyte/chars.rb in radiant-0.6.4 vs vendor/rails/activesupport/lib/active_support/multibyte/chars.rb in radiant-0.6.5
- old
+ new
@@ -39,10 +39,16 @@
# 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
@@ -111,11 +117,17 @@
private
# +utf8_pragma+ checks if it can send this string to the handlers. It makes sure @string isn't nil and $KCODE is
# set to 'UTF8'.
- def utf8_pragma?
- !@string.nil? && ($KCODE == 'UTF8')
+ if RUBY_VERSION < '1.9'
+ def utf8_pragma?
+ !@string.nil? && ($KCODE == 'UTF8')
+ end
+ else
+ def utf8_pragma?
+ !@string.nil? && (Encoding.default_external == Encoding::UTF_8)
+ end
end
end
end
# When we can load the utf8proc library, override normalization with the faster methods