提交 bd852603 编写于 作者: S Steve Klabnik

Simplify String#mb_chars and stop proxying #class

This behavior mattered under Ruby 1.8, but that doesn't matter now
that we don't support it.

In addition, we don't want to proxy the #class method. A test was added
to prevent against regressions.
上级 27b79f4c
## Rails 4.0.0 (unreleased) ##
* No longer proxy ActiveSupport::Multibyte#class. *Steve Klabnik*
* Deprecate `ActiveSupport::TestCase#pending` method, use `skip` from MiniTest instead. *Carlos Antonio da Silva*
* `XmlMini.with_backend` now may be safely used with threads:
......
......@@ -33,11 +33,7 @@ class String
# For more information about the methods defined on the Chars proxy see ActiveSupport::Multibyte::Chars. For
# information about how to change the default Multibyte behavior see ActiveSupport::Multibyte.
def mb_chars
if ActiveSupport::Multibyte.proxy_class.consumes?(self)
ActiveSupport::Multibyte.proxy_class.new(self)
else
self
end
ActiveSupport::Multibyte.proxy_class.new(self)
end
def is_utf8?
......
......@@ -47,7 +47,7 @@ def test_forwarded_bang_method_calls_should_return_nil_when_result_is_nil
end
def test_methods_are_forwarded_to_wrapped_string_for_byte_strings
assert_equal BYTE_STRING.class, BYTE_STRING.mb_chars.class
assert_equal BYTE_STRING.length, BYTE_STRING.mb_chars.length
end
def test_forwarded_method_with_non_string_result_should_be_returned_vertabim
......@@ -673,6 +673,9 @@ def test_tidy_bytes_should_forcibly_tidy_bytes_if_specified
assert_equal "𥤤", chars(byte_string).tidy_bytes(true)
end
def test_class_is_not_forwarded
assert_equal BYTE_STRING.dup.mb_chars.class, ActiveSupport::Multibyte::Chars
end
private
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册