#165 open
Daniel Parker

to_xml for collections - Model.first.to_xml works but Model.all.to_xml doesn't.

Reported by Daniel Parker | February 22nd, 2008 @ 12:04 PM | in 1.x

It could be argued that defining to_xml for Arrays should be someone else's problem, but my opinion is that it would honor consistency to make this work.

The problem is quite simple: Given a datamapper model, Model, I can do Model.first.to_xml and it will give me xml. But I can't do Model.all.to_xml, which should be possible.

My suggestion is to use a collection class just like associations do, instead of a simple Array, when returning lists of datamapper objects. This collection, then, would have methods like to_xml, to_json. It would also be handy if the collection behavior could be applied to an array, or created from an array, for cases where the user may need to collect objects manually into a collection with this behavior.

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Tags