Forum: Ruby YAML and class variables

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7c63d256573b4235230aee9110623a00?d=identicon&s=25 Rick Ashton (kly)
on 2007-01-03 12:22
Hi

When an object's .to_yaml method is used, class variables aren't
recorded. This makes sense, I guess, but how can someone then serialize
a class variable and restore it later?

Thanks!
kLy
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2007-01-03 12:56
(Received via mailing list)
On 03.01.2007 12:22, Rick Ashton wrote:
> When an object's .to_yaml method is used, class variables aren't
> recorded. This makes sense, I guess, but how can someone then serialize
> a class variable and restore it later?

You don't.  Basically a class variable belongs to the class and that's
typically not created via some serialization mechanism (yaml, marshal)
but through code.  Apart from that class variables have a whole bunch of
problems of their own so you better avoid them anyway.  My 0.02 EUR...

Kind regards

	robert
This topic is locked and can not be replied to.