To_xml follows different path for collections than for individual objects

For example:

I have an item
and in script/console of my project I do:

item.to_xml

This executes through an elaborate path of modules and methods
something like this:

 to_xml --> XmlSerializer --> which calls to_s, which is

an alias in xml_serialization.rb for the method serialize. Serialize
calls a method “builder” to make a new Builder::XmlMarkup (which
extends from XmlBase). With this, the builder tags the attributes
as needed.

However, if I try it with an array of items I can’t figure out where
it goes to and in what order.

By putting out little notices in the different methods I mentioned
above it would seem that to_xml with a collection goes in a nearly
reverse order from a single item.

The purpose of all of this is an attempt to add on option for to_xml
that would allow it to skip escaping the xml unicode into html
entities (using _escape --> Xchar#to_xs).

Thanks for any hints. It would be nice to learn how to actually debug
something like this.

On 8 Nov 2007, at 15:33, thanatos wrote:

However, if I try it with an array of items I can’t figure out where
it goes to and in what order.

By putting out little notices in the different methods I mentioned
above it would seem that to_xml with a collection goes in a nearly
reverse order from a single item.

check out to_xml in activesupport/lib/active_support/core_ext/array/
conversions.rb

The purpose of all of this is an attempt to add on option for to_xml
that would allow it to skip escaping the xml unicode into html
entities (using _escape --> Xchar#to_xs).

Thanks for any hints. It would be nice to learn how to actually debug
something like this.

step through it with rdebug ?

Fred