I'm not in a position to test, but it looksnto me like the method =20
print simply isn't created on the unMarshaled object. Since the =20
methods in Kernel are included in Object as private methods, you get =20
the same error message from Object.new.print or Object.new.throw. I'm =20=

not familiar with Marshaling at all, but this may help you debug. Good =20=

luck :)

--=20
Mikael H=A9=AAilund, CTO of Meta.io

On Aug 20, 2008, at 6:17 AM, Patrick Li <patrickli_2001 / hotmail.com> =20
wrote:

> I noticed this this afternoon:
> Unmarshaling a marshaled object, makes all dynamically created methods
> private.
>
> #Here's a class that dynamically creates the method MyPage#print()
> class MyPage
>  def initialize
>    MyPage.class_eval do
>      def print
>        puts @a
>      end
>    end
>  end
> end
>
> #Test the class
> page =3D MyPage.new
> page.print #prints nil
>
> #Marshal the object
> File.open("object.obj","w") do |f|
>  Marshal.dump(page, f)
> end
>
> #UnMarshal the object, and try printing again
> page =3D nil
> File.open("object.obj","r") do |f|
>  page =3D Marshal.load(f)
> end
> page.print
>
> #gives me:
> #private method `print' called for #<MyPage:0x27af394 @a=3D3>
> (NoMethodError)
> --=20
> Posted via http://www.ruby-forum.com/.
>