Sha256: f123c8bf99d9f219af3ddf4a0873efa0dbe9c29154f47314a8db633db269c3b4

Contents?: true

Size: 710 Bytes

Versions: 5

Compression:

Stored size: 710 Bytes

Contents

require 'active_support/core_ext/module/delegation'

module ActiveSupport
  # = XmlMini
  #
  # To use the much faster libxml parser:
  #   gem 'libxml-ruby', '=0.9.7'
  #   XmlMini.backend = 'LibXML'
  module XmlMini
    extend self

    attr_reader :backend
    delegate :parse, :to => :backend

    def backend=(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

  XmlMini.backend = 'REXML'
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
activesupport-3.0.0.beta3 lib/active_support/xml_mini.rb
activesupport-3.0.0.beta2 lib/active_support/xml_mini.rb
activesupport-3.0.0.beta lib/active_support/xml_mini.rb
activesupport-3.0.pre lib/active_support/xml_mini.rb
recliner-0.0.1 vendor/activesupport/lib/active_support/xml_mini.rb