https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2373-record-sensitive-procs-for-to_xml

This is a patch that I contributed a couple of months ago. In short,
the point is to enable procs to access the record being serialized by
adding support for another argument in proc's goalposts. With this
patch you can no do something like:

proc = Proc.new { |options, record| options[:builder].tag!('name-
reverse', record.name.reverse) }
@records.to_xml :procs => [ proc ]

Which would, of course, add a reversed string of the name to each
serialized record.

to_xml is incredibly convenient when used to serialize AR objects,
because it provides a short-hand for expressing those objects without
having to resort to builder templates, hand-drawn builder instances,
and such.  I think that this patch will make that expression much more
powerful without requiring invasive changes.

Further: 
http://stackoverflow.com/questions/260668/building-dynamic-fields-using-activerecordserialization-toxml

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to