[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby 1.8 and marshal_dump issue

Michael Davis

10/10/2003 8:12:00 PM

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


2 Answers

NAKAMURA, Hiroshi

10/10/2003 11:51:00 PM

0

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

Michael Davis

10/18/2003 6:42:00 PM

0

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
>
>
>