lib/model_xml/generator.rb in model_xml-1.0.9 vs lib/model_xml/generator.rb in model_xml-1.0.11

- old
+ new

@@ -1,9 +1,8 @@ require 'rubygems' require 'builder' require 'nokogiri' -require 'facets/string/snakecase' require 'model_xml/block_parser' module ModelXML class Generator @@ -79,12 +78,15 @@ unless options[:skip_instruct] xml.instruct! end - xml.tag! object.class.to_s.snakecase do + root_node = object.class.to_s + root_node = root_node.underscore if root_node.respond_to?(:underscore) # Rails only + xml.tag! root_node do + field_list.each do |field| # if the field is a symbol, treat it as the field name and the getter method if field.is_a?(Symbol) tag = field @@ -105,10 +107,10 @@ # do nothing else # if the content responds to to_xml, call it passing the current builder if content.respond_to?(:to_xml) - content.to_xml(options.merge(:builder => xml, :skip_instruct => true, :root => tag.to_s)) + content.to_xml(options.merge(:builder => xml, :skip_instruct => true, :root => tag.to_s, :dasherize => false)) # otherwise create the tag normally else xml.tag! tag, content end