How to tell Ruby not to serialize an attribute or how to overload marshal_dump properly?

Posted by GregMoreno on Stack Overflow See other posts from Stack Overflow or by GregMoreno
Published on 2010-05-04T18:05:51Z Indexed on 2010/05/04 18:08 UTC
Read the original article Hit count: 145

Filed under:
|

I have an attribute in my AR:B that is not serializeable.

o = Discussion.find(6)
Marshal.dump(o)

TypeError: no marshal_dump is defined for class Proc
       from (irb):10:in `dump'

I know the culprit and what I want is to set this variable to nil before any serialization takes place.

I can do this but I'm stuck with the proper way to override marshal_dump

 def marshal_dump
   @problem = nil
   # what is the right return here?
 end

Or is there is way to tell Ruby or AR not to serialize an object?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about marshalling