Module: OEmbed::Formatter::XML

Extended by:
Base
Defined in:
lib/oembed/formatter/xml.rb,
lib/oembed/formatter/xml/backends/rexml.rb,
lib/oembed/formatter/xml/backends/nokogiri.rb,
lib/oembed/formatter/xml/backends/xmlsimple.rb

Overview

Handles parsing XML values using the best available backend.

Defined Under Namespace

Modules: Backends

Constant Summary

DECODERS =

A Array of all available backends, listed in order of preference.

%w(XmlSimple REXML)

Class Method Summary (collapse)

Methods included from Base

backend=, decode, supported?, with_backend

Class Method Details

+ (Object) backend

Returns the current XML backend.



12
13
14
15
16
# File 'lib/oembed/formatter/xml.rb', line 12

def backend
  set_default_backend unless defined?(@backend)
  raise OEmbed::FormatNotSupported, :xml unless defined?(@backend)
  @backend
end

+ (Object) set_default_backend



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/oembed/formatter/xml.rb', line 18

def set_default_backend
  DECODERS.find do |name|
    begin
      self.backend = name
      true
    rescue LoadError
      # Try next decoder.
      false
    end
  end
end