Permalink
Browse files

Add documentation for Hash.from_xml [ci skip]

  • Loading branch information...
1 parent fb39249 commit 96f7ec4537e8618855467e7226d11182bd8a1111 @hpneo hpneo committed Dec 1, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 activesupport/lib/active_support/core_ext/hash/conversions.rb
@@ -88,6 +88,19 @@ def to_xml(options = {})
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

0 comments on commit 96f7ec4

Please sign in to comment.