--- Michael Neumann <mneumann / ntecs.de> wrote:
> How about this:
> 
>   module Kernel
>     def to_yaml
>       if respond_to? :_dump
>         _dump(nil).to_yaml    # TODO: _dump takes one paramter
>       else
>         raise 
>       end
>     end
>   end

That would be a nice solution. But the string returned by _dump
probably won't be valid YAML.

If I have the following class

class Foo
  def _dump(x)
    "foo"
  end

  def to_yaml
    _dump
  end
end

then YAML.dump(Foo.new) will return "foo". But that's no good, since
there's nothing to tell it that this "foo" should be de-YAMLed into a
new Foo instance.
Marshal.dump(Foo.new) will return "\004\010u:\010Foo\010foo", with all
the needed meta-data.

> _load is a class method!

Yes. :) But what's the corresponding method for YAML?

/Anders


=====
__________________________________________________
Anders Bengtsson              ndrsbngtssn / yahoo.se
Stockholm, Sweden

H÷ˇtrusk och grmoln - k÷­ en resa till solen pYahoo! Resor padressen http://se.docs.yahoo.com/travel/index.html