提交 5d3712a8 编写于 作者: J Jeremy Kemper

Hack builder to look for fast_xs instead of insisting on its own String#to_xs

上级 6de241be
......@@ -18,7 +18,6 @@ def self.check_for_name_collision(klass, method_name, defined_constant=nil)
end
if ! defined?(Builder::XChar)
Builder.check_for_name_collision(String, "to_xs")
Builder.check_for_name_collision(Fixnum, "xchr")
end
......@@ -105,11 +104,12 @@ def xchr
# Enhance the String class with a XML escaped character version of
# to_s.
#
require 'active_support/core_ext/string/xchar'
class String
# XML escaped version of to_s
def to_xs
unpack('U*').map {|n| n.xchr}.join # ASCII, UTF-8
rescue
unpack('C*').map {|n| n.xchr}.join # ISO-8859-1, WIN-1252
end
end unless method_defined?(:to_xs)
end
require 'abstract_unit'
require 'builder'
class HashExtTest < Test::Unit::TestCase
def setup
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册