Serializing AR Objects

I need to serialize a composite AR model and save it to a database
field.

Reading up on Ruby’s Marshaling, it seems there could be problems
with the version numbering thing of the default dump/load methods.

As I understand it, Ruby internally marks the serialized data with
the current Ruby language version, and when loading that data, if the
major version is changed, the loading is aborted. Seems like a rather
extreme measure compared to testing a version or formatting of the
serialized data itself rather than the language version. Or have I
read this wrong, and these version numbers are for the marshaling
format and not the whole language?

Considering 1.9 is not too far away (from an application life-cycle
perspective), this would seem to be a potential big problem.

Is my only option to create custom marshaling methods? That would
seem to be a rather tedious thing to do for a complex composite
ActiveRecord object.

– gw

On May 13, 2008, at 11:47 AM, Greg W. wrote:

As I understand it, Ruby internally marks the serialized data with
the current Ruby language version, and when loading that data, if the
major version is changed, the loading is aborted. Seems like a rather
extreme measure compared to testing a version or formatting of the
serialized data itself rather than the language version. Or have I
read this wrong, and these version numbers are for the marshaling
format and not the whole language?

DOH! I just now saw one short, buried sentence that clarified that
marshal versioning is separate from the language versioning. Question
answered.

– gw

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs