Module: DataMapper::Serializer::XML

Defined in:
lib/dm-serializer/xml.rb,
lib/dm-serializer/xml/rexml.rb,
lib/dm-serializer/xml/libxml.rb,
lib/dm-serializer/xml/nokogiri.rb

Defined Under Namespace

Modules: LibXML, Nokogiri, REXML

Constant Summary collapse

SERIALIZERS =

The supported XML Serializers

{
  :libxml => 'LibXML',
  :nokogiri => 'Nokogiri',
  :rexml => 'REXML'
}

Class Method Summary collapse

Class Method Details

.serializerModule

The current XML Serializer.

Returns:

Since:

  • 1.1.0



19
20
21
# File 'lib/dm-serializer/xml.rb', line 19

def self.serializer
  @serializer
end

.serializer=(name) ⇒ Module

Sets the XML Serializer to use.

Parameters:

  • name (Symbol)

    The name of the serializer to use. Must be either ‘:libxml`, `:nokogiri` or `:rexml`.

Returns:

Since:

  • 1.1.0



35
36
37
38
39
40
41
42
43
44
# File 'lib/dm-serializer/xml.rb', line 35

def self.serializer=(name)
  serializer_const = SERIALIZERS[name]

  unless serializer_const
    raise(ArgumentError,"unsupported XML Serializer #{name}")
  end

  require "dm-serializer/xml/#{name}"
  @serializer = const_get(serializer_const)
end