Skip to content
Browse files

Renamed DataMapper::Serialize::XMLSerializers to XML.

* Since the module is already defined under the Serialize namespace.
  • Loading branch information...
1 parent 4c609a1 commit f7b429bc2c9402ee95b5c38c0874d0c20cc0cdb5 @postmodern postmodern committed Mar 9, 2011
View
10 lib/dm-serializer/to_xml.rb
@@ -1,5 +1,5 @@
require 'dm-serializer/common'
-require 'dm-serializer/xml_serializers'
+require 'dm-serializer/xml'
module DataMapper
module Serialize
@@ -9,7 +9,7 @@ module Serialize
# An XML representation of this Resource.
#
def to_xml(opts = {})
- xml = XMLSerializers.serializer
+ xml = XML.serializer
xml.output(to_xml_document(opts)).to_s
end
@@ -20,7 +20,7 @@ def to_xml(opts = {})
# add_property_node
# add_node
def to_xml_document(opts={}, doc = nil)
- xml = XMLSerializers.serializer
+ xml = XML.serializer
doc ||= xml.new_document
default_xml_element_name = lambda { DataMapper::Inflector.underscore(model.name).tr("/", "-") }
root = xml.root_node(doc, opts[:element_name] || default_xml_element_name[])
@@ -53,7 +53,7 @@ def to_xml(opts = {})
end
def to_xml_document(opts = {})
- xml = DataMapper::Serialize::XMLSerializers.serializer
+ xml = DataMapper::Serialize::XML.serializer
doc = xml.new_document
root = xml.root_node(doc, "errors", {'type' => 'hash'})
@@ -78,7 +78,7 @@ def to_xml(opts = {})
end
def to_xml_document(opts = {})
- xml = DataMapper::Serialize::XMLSerializers.serializer
+ xml = DataMapper::Serialize::XML.serializer
doc = xml.new_document
default_collection_element_name = lambda {DataMapper::Inflector.pluralize(DataMapper::Inflector.underscore(self.model.to_s)).tr("/", "-")}
root = xml.root_node(doc, opts[:collection_element_name] || default_collection_element_name[], {'type' => 'array'})
View
8 lib/dm-serializer/xml_serializers.rb → lib/dm-serializer/xml.rb
@@ -1,6 +1,6 @@
module DataMapper
module Serialize
- module XMLSerializers
+ module XML
# The supported XML Serializers
SERIALIZERS = {
:libxml => 'LibXML',
@@ -12,7 +12,7 @@ module XMLSerializers
# The current XML Serializer.
#
# @return [Module]
- # The module within {DataMapper::Serialize::XMLSerializers}.
+ # The module within {DataMapper::Serialize::XML}.
#
# @since 1.1.0
#
@@ -28,7 +28,7 @@ def self.serializer
# `:nokogiri` or `:rexml`.
#
# @return [Module]
- # The module within {DataMapper::Serialize::XMLSerializers}.
+ # The module within {DataMapper::Serialize::XML}.
#
# @since 1.1.0
#
@@ -39,7 +39,7 @@ def self.serializer=(name)
raise(ArgumentError,"unsupported XML Serializer #{name}")
end
- require "dm-serializer/xml_serializers/#{name}"
+ require "dm-serializer/xml/#{name}"
@serializer = const_get(serializer_const)
end
View
2 lib/dm-serializer/xml_serializers/libxml.rb → lib/dm-serializer/xml/libxml.rb
@@ -2,7 +2,7 @@
module DataMapper
module Serialize
- module XMLSerializers
+ module XML
module LibXML
def self.new_document
::LibXML::XML::Document.new
View
2 ...dm-serializer/xml_serializers/nokogiri.rb → lib/dm-serializer/xml/nokogiri.rb
@@ -2,7 +2,7 @@
module DataMapper
module Serialize
- module XMLSerializers
+ module XML
module Nokogiri
def self.new_document
::Nokogiri::XML::Document.new
View
2 lib/dm-serializer/xml_serializers/rexml.rb → lib/dm-serializer/xml/rexml.rb
@@ -2,7 +2,7 @@
module DataMapper
module Serialize
- module XMLSerializers
+ module XML
module REXML
def self.new_document
::REXML::Document.new
View
2 spec/public/to_xml_spec.rb
@@ -3,7 +3,7 @@
[:rexml, :libxml, :nokogiri].each do |lib|
begin
- DataMapper::Serialize::XMLSerializers.serializer = lib
+ DataMapper::Serialize::XML.serializer = lib
rescue LoadError => e
warn "[WARNING] #{e.message}"
warn "[WARNING] Not running #to_xml specs for #{lib}"

0 comments on commit f7b429b

Please sign in to comment.
Something went wrong with that request. Please try again.