From 96f7ec4537e8618855467e7226d11182bd8a1111 Mon Sep 17 00:00:00 2001 From: HPNeo Date: Sat, 1 Dec 2012 14:57:27 -0500 Subject: Add documentation for Hash.from_xml [ci skip] --- .../lib/active_support/core_ext/hash/conversions.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activesupport/lib/active_support/core_ext') 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 + # + # + # 1 + # 2 + # + # 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 -- cgit v1.2.3