diff options
author | HPNeo <hpneo@hotmail.com> | 2012-12-01 14:57:27 -0500 |
---|---|---|
committer | HPNeo <hpneo@hotmail.com> | 2012-12-01 14:57:34 -0500 |
commit | 96f7ec4537e8618855467e7226d11182bd8a1111 (patch) | |
tree | dd840dbb36ed58c26b866714f487d8f39ed40acd /activesupport/lib | |
parent | fb39249f368bca4563e31939a3439277201b641f (diff) | |
download | rails-96f7ec4537e8618855467e7226d11182bd8a1111.tar.gz rails-96f7ec4537e8618855467e7226d11182bd8a1111.tar.bz2 rails-96f7ec4537e8618855467e7226d11182bd8a1111.zip |
Add documentation for Hash.from_xml [ci skip]
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/conversions.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb index 85b0e10be2..e1ce9f371a 100644 --- a/activesupport/lib/active_support/core_ext/hash/conversions.rb +++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb @@ -88,6 +88,19 @@ class Hash end class << self + # Returns a Hash containing a collection of pairs when the key is the node name and the value is + # its content + # + # xml = <<-XML + # <?xml version="1.0" encoding="UTF-8"?> + # <hash> + # <foo type="integer">1</foo> + # <bar type="integer">2</bar> + # </hash> + # XML + # + # hash = Hash.from_xml(xml) + # # => {"hash"=>{"foo"=>1, "bar"=>2}} def from_xml(xml) typecast_xml_value(unrename_keys(ActiveSupport::XmlMini.parse(xml))) end |