Railsters:

I suspect the answer is "because they invented it before inventing eager 
loading".

The first minor issue with to_xml's refusal to read my mind is it's not DRY
(like my mind!):

    Model.all(:include =>{ :this => :that }).
      to_xml(:include =>{ :this => :that })

With eager loading, every Model instance has its internal @this member
populated, and each This has its @that populated. So, instead of repeating the
:include argument, to_xml could just find every populated @this and @that
instance variable, and recursively call to_xml on it.

Do I misunderstand to_xml here? Or is it indeed refusing to read my mind?

Another, more minor issue: to_xml( :except =>[ :secret, :password ] )

Is there, instead, a :pass argument, to positively declare what we _do_ want?
Negatively declaring the complete list of variables we _don't_ want (being most
of them) is not just a waste of time, it's fragile if we migrate more secret
fields into our model!

Please advise if I need to RFTM, grab a plugin, or else just live with to_xml's
disturbing refusal to read my mind!

-- 
   Phlip


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to