#165 ✓resolved
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

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 Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

People watching this ticket

Referenced by

Pages