You are using Nokogiri builder to create the XML output, which as you know, uses a Hash to pass in attribute key/value pairs when adding a new element. I am using Ruby 1.8.7, which (unlike Ruby 1.9.3) does not retain the insertion order of the items that are added to a Hash object. Therefore the to_xml method is currently outputting xml in which the attribute sequence is somewhat abitratry.
In my installation of unhappymapper, I altered this behavior by installing the new activemodel gem, then added
require "active_model"
at the top of the file, and replaced the line:
attributes = Hash[ *attributes ]
with
attributes = ActiveSupport::OrderedHash[ *attributes ]
With this change the attributes are output in the sequence they appear in the Ruby class.
(I know, I know -- the XML spec says that attribute order is supposed to be arbitrary, but I like my xml to be consistent)
You are using Nokogiri builder to create the XML output, which as you know, uses a Hash to pass in attribute key/value pairs when adding a new element. I am using Ruby 1.8.7, which (unlike Ruby 1.9.3) does not retain the insertion order of the items that are added to a Hash object. Therefore the to_xml method is currently outputting xml in which the attribute sequence is somewhat abitratry.
In my installation of unhappymapper, I altered this behavior by installing the new activemodel gem, then added
require "active_model"
at the top of the file, and replaced the line:
attributes = Hash[ *attributes ]
with
attributes = ActiveSupport::OrderedHash[ *attributes ]
With this change the attributes are output in the sequence they appear in the Ruby class.
(I know, I know -- the XML spec says that attribute order is supposed to be arbitrary, but I like my xml to be consistent)