Custom serialization scheme

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

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?


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