aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/xml_mini/rexml.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-05-18 11:54:51 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-05-18 11:54:51 -0700
commitcf6e025a4538e488ed35f61f1f7f3498833a34e6 (patch)
tree6a28d5beac35e74a33243668baf7a9a60edf6724 /activesupport/lib/active_support/xml_mini/rexml.rb
parent628110d7eeb446fee7f9e043f113c083d24883c1 (diff)
parent195fadbfd31294d43634afb7bbf4f0ffc86b470a (diff)
downloadrails-cf6e025a4538e488ed35f61f1f7f3498833a34e6.tar.gz
rails-cf6e025a4538e488ed35f61f1f7f3498833a34e6.tar.bz2
rails-cf6e025a4538e488ed35f61f1f7f3498833a34e6.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activesupport/lib/active_support/xml_mini/rexml.rb')
-rw-r--r--activesupport/lib/active_support/xml_mini/rexml.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/xml_mini/rexml.rb b/activesupport/lib/active_support/xml_mini/rexml.rb
index 5033210aae..1184d2d6c9 100644
--- a/activesupport/lib/active_support/xml_mini/rexml.rb
+++ b/activesupport/lib/active_support/xml_mini/rexml.rb
@@ -7,16 +7,20 @@ module ActiveSupport
CONTENT_KEY = '__content__'.freeze
- # Parse an XML Document string into a simple hash
+ # Parse an XML Document string or IO into a simple hash
#
# Same as XmlSimple::xml_in but doesn't shoot itself in the foot,
# and uses the defaults from ActiveSupport
#
- # string::
- # XML Document string to parse
- def parse(string)
+ # data::
+ # XML Document string or IO to parse
+ def parse(data)
+ if data.respond_to?(:read)
+ data = data.read
+ end
+
require 'rexml/document' unless defined?(REXML::Document)
- doc = REXML::Document.new(string)
+ doc = REXML::Document.new(data)
merge_element!({}, doc.root)
end