lib/dm-serializer/to_xml.rb in dm-serializer-0.10.1 vs lib/dm-serializer/to_xml.rb in dm-serializer-0.10.2

- old
+ new

@@ -10,11 +10,10 @@ def to_xml(opts = {}) xml = XMLSerializers::SERIALIZER xml.output(to_xml_document(opts)).to_s end - protected # This method requires certain methods to be implemented in the individual # serializer library subclasses: # new_document # root_node # add_property_node @@ -23,22 +22,22 @@ xml = XMLSerializers::SERIALIZER doc ||= xml.new_document default_xml_element_name = lambda { Extlib::Inflection.underscore(model.name).tr("/", "-") } root = xml.root_node(doc, opts[:element_name] || default_xml_element_name[]) properties_to_serialize(opts).each do |property| - value = send(property.name) + value = __send__(property.name) attrs = (property.type == String) ? {} : {'type' => property.type.to_s.downcase} xml.add_node(root, property.name.to_s, value, attrs) end (opts[:methods] || []).each do |meth| if self.respond_to?(meth) xml_name = meth.to_s.gsub(/[^a-z0-9_]/, '') - value = send(meth) + value = __send__(meth) unless value.nil? if value.respond_to?(:to_xml_document) - xml.add_xml(root, value.send(:to_xml_document)) + xml.add_xml(root, value.to_xml_document) else xml.add_node(root, xml_name, value.to_s) end end end @@ -50,19 +49,17 @@ class Collection def to_xml(opts = {}) to_xml_document(opts).to_s end - protected - def to_xml_document(opts = {}) xml = DataMapper::Serialize::XMLSerializers::SERIALIZER doc = xml.new_document default_collection_element_name = lambda {Extlib::Inflection.pluralize(Extlib::Inflection.underscore(self.model.to_s)).tr("/", "-")} root = xml.root_node(doc, opts[:collection_element_name] || default_collection_element_name[], {'type' => 'array'}) self.each do |item| - item.send(:to_xml_document, opts, doc) + item.to_xml_document(opts, doc) end doc end end @@ -71,11 +68,9 @@ module Validate class ValidationErrors def to_xml(opts = {}) to_xml_document(opts).to_s end - - protected def to_xml_document(opts = {}) xml = DataMapper::Serialize::XMLSerializers::SERIALIZER doc = xml.new_document root = xml.root_node(doc, "errors", {'type' => 'hash'})