aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/xml_mini.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/xml_mini.rb')
-rw-r--r--activesupport/lib/active_support/xml_mini.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/xml_mini.rb b/activesupport/lib/active_support/xml_mini.rb
index 0513c0d4d0..ccd1349491 100644
--- a/activesupport/lib/active_support/xml_mini.rb
+++ b/activesupport/lib/active_support/xml_mini.rb
@@ -6,15 +6,24 @@ module ActiveSupport
# XmlMini.backend = 'LibXML'
module XmlMini
extend self
- delegate :parse, :to => :@backend
- class << self
- attr_reader :backend
- end
+ attr_reader :backend
+ delegate :parse, :to => :backend
def backend=(name)
- require "active_support/xml_mini/#{name.to_s.downcase}.rb"
- @backend = ActiveSupport.const_get("XmlMini_#{name}")
+ if name.is_a?(Module)
+ @backend = name
+ else
+ require "active_support/xml_mini/#{name.to_s.downcase}.rb"
+ @backend = ActiveSupport.const_get("XmlMini_#{name}")
+ end
+ end
+
+ def with_backend(name)
+ old_backend, self.backend = backend, name
+ yield
+ ensure
+ self.backend = old_backend
end
end