Forum: Ruby Custom serialization scheme

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Wes G. (Guest)
on 2006-05-08 22:31
I have an object with one attribute that is unserializable (due to it's
containing a Proc).

I am trying to figure out how to do the customized serialization
routines for it.

Assume that my attribute that I don't want to serialize is named
@transient.  If I wanted to make sure that @transient didn't get dumped,
couldn't I just do:

def marshal_dump
  @transient = nil
  self._dump
end

I'm basically wanting to take advantage of the built-in serialization
but exclude one attribute from it.

Would I have to also create a marshal_load method in this case?

Am I required to come up with a custom marshaling and unmarshaling
scheme for _all_ of the N-1 attributes that I _do_ want to have be
serializable, in order to just exclude this one?

Thanks,
Wes
This topic is locked and can not be replied to.