aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2012-12-04 22:26:16 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2012-12-04 22:26:16 +0530
commit40e16121c05f10f9b75b6cd68c32092876142861 (patch)
treeef029336773e706cad2442d232a184ff0db38efe /activesupport/lib/active_support/core_ext
parent9d3ce6c7d24fb8fe63f4bde4718e6af6225e5a98 (diff)
parent2b847a0a9b56c7ede40012c7b3bd8ec90d6c111c (diff)
downloadrails-40e16121c05f10f9b75b6cd68c32092876142861.tar.gz
rails-40e16121c05f10f9b75b6cd68c32092876142861.tar.bz2
rails-40e16121c05f10f9b75b6cd68c32092876142861.zip
Merge branch 'master' of github.com:lifo/docrails
Conflicts: guides/source/migrations.md
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/conversions.rb13
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