How to store/load persistent data?
In my previous life (in perl-world) I was used to store persistent data
with Data::Dumper and load it back with "require '/path/to/file'".
Now I'm learing ruby and started my first toy-project. I must admit that
I am not very familiar with OO techniques.
AFAICS, the ruby way to store persistent data is YAML. Saving an object
with YAML.dump() works like a charm. But I have trouble to read them
back with YAML.load(). For some reason, the initialize() method of the
loaded object doesn't get called. I don't understand how an object can
properly spring in existance without the initialize method? For example,
I allocate a TkCanvas in the initialize() method. Such an object can not
be loaded back properly, IMHO.
I have one more problem with such an object: There's no destructor. Should
such an object get out of scope, how do I make sure the allocated canvas
is destroyed properly?
I'm sorry if this is a stupid question, but I am new to both, ruby and OO.
Please can somebody give an explanation how such an object is handled in
|All times are GMT. The time now is 11:50 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.