提交 1ec9f8d0 编写于 作者: R Rick Olson

Correctly convert <foo nil=true> to nil when using Hash.create_from_xml. [Rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4607 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 35f7cc23
*SVN* *SVN*
* Correctly convert <foo nil="true"> to nil when using Hash.create_from_xml. [Rick]
* Optional identity for Enumerable#sum defaults to zero. #5657 [gensym@mac.com] * Optional identity for Enumerable#sum defaults to zero. #5657 [gensym@mac.com]
* HashWithIndifferentAccess shouldn't confuse false and nil. #5601 [shugo@ruby-lang.org] * HashWithIndifferentAccess shouldn't confuse false and nil. #5601 [shugo@ruby-lang.org]
......
...@@ -101,7 +101,7 @@ def typecast_xml_value(value) ...@@ -101,7 +101,7 @@ def typecast_xml_value(value)
else content else content
end end
else else
value.empty? ? nil : value.inject({}) do |h,(k,v)| value.empty? || value['nil'] == 'true' ? nil : value.inject({}) do |h,(k,v)|
h[k] = typecast_xml_value(v) h[k] = typecast_xml_value(v)
h h
end end
......
...@@ -352,7 +352,7 @@ def test_multiple_records_from_xml ...@@ -352,7 +352,7 @@ def test_multiple_records_from_xml
<viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at> <viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at>
<content>Have a nice day</content> <content>Have a nice day</content>
<author-email-address>david@loudthinking.com</author-email-address> <author-email-address>david@loudthinking.com</author-email-address>
<parent-id></parent-id> <parent-id nil="true"></parent-id>
</topic> </topic>
<topic> <topic>
<title>The Second Topic</title> <title>The Second Topic</title>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册