I notice how Rails makes heavy use of YAML serialization, but a lot of the Ruby literature I come across places emphasis on Marshal. One powerful technique with marshal is the marshal_dump and marshal_load hooks used to customize storing and retrieving object states. For example, let’s say I have an object that can store as instance variables an arbitrary array of integers. And let’s say I simply want to marshal that array rather than the whole object state, and then later retrieve that data and store it into an allocated but unitialized new instance of the object. Then the marshal_dump and marshal_load hooks come in handy:
@coords = coords
@coords = s.unpack(“w*”)
Is there a more effective way to achieve something like this in YAML that the Rails community prefers?