aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/xml_mini/rexml.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/xml_mini/rexml.rb')
-rw-r--r--activesupport/lib/active_support/xml_mini/rexml.rb16
1 files changed, 11 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/xml_mini/rexml.rb b/activesupport/lib/active_support/xml_mini/rexml.rb
index 771109514c..1184d2d6c9 100644
--- a/activesupport/lib/active_support/xml_mini/rexml.rb
+++ b/activesupport/lib/active_support/xml_mini/rexml.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/object/blank'
+
# = XmlMini ReXML implementation
module ActiveSupport
module XmlMini_REXML #:nodoc:
@@ -5,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