Ruby 1.8 and marshal_dump issue

Hello all,

I have an issue with marshal_dump in Ruby 1.8 that I can’t seem to work around. I have a Hash the contains a proc object and I need to Marshal.dump the Hash. I have included a marshal_dump method to eliminate the proc object from the Hash but I still get an error during the Marshal.dump. The error message is:

“class Proc needs to have instance method `_dump_data’”

Any suggestions is greatly appreciated.

Here is a very specific example that reproduces the error:

class MyClass < Hash
def initialize(attr)
self.update(attr)
end
def marshal_dump() #:nodoc:
self.delete(:test)
puts self.inspect
super
end
end

a = MyClass.new(:test=>proc{puts ‘test’}, :test2=>2)
puts Marshal.dump(a).inspect
exit

Thanks in advance, Michael Davis

Hi, Michael,

From: “Michael Davis” mdavis@sevasoftware.com
Sent: Saturday, October 11, 2003 5:12 AM

I have included a marshal_dump method to eliminate the proc object
from the Hash but I still get an error during the Marshal.dump.
The error message is:

“class Proc needs to have instance method `_dump_data’”

marshal_dump feature/implementation has been changing in a few or more days.
Try CVS HEAD. Your sample code should work as you expected now.

Regards,
// NaHi

Thanks, this addressed the issue.

NAKAMURA, Hiroshi wrote:

···

Hi, Michael,

From: “Michael Davis” mdavis@sevasoftware.com
Sent: Saturday, October 11, 2003 5:12 AM

I have included a marshal_dump method to eliminate the proc object
from the Hash but I still get an error during the Marshal.dump.
The error message is:

“class Proc needs to have instance method `_dump_data’”

marshal_dump feature/implementation has been changing in a few or more days.
Try CVS HEAD. Your sample code should work as you expected now.

Regards,
// NaHi