Ruby 1.8 and marshal_dump issue

M

Michael Davis

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
 
N

NAKAMURA, Hiroshi

Hi, Michael,
From: "Michael Davis" <[email protected]>
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
 
M

Michael Davis

Thanks, this addressed the issue.

Hi, Michael,




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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top