How to store/load persistent data?

Discussion in 'Ruby' started by Josef Wolf, Sep 4, 2006.

  1. Josef Wolf

    Josef Wolf Guest

    Hello!

    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
    the ruby-world?
    Josef Wolf, Sep 4, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. NWx
    Replies:
    2
    Views:
    364
  2. =?Utf-8?B?UnVkeQ==?=

    to store or not to store an image

    =?Utf-8?B?UnVkeQ==?=, Mar 29, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    621
    =?Utf-8?B?UnVkeQ==?=
    Mar 30, 2005
  3. gk
    Replies:
    7
    Views:
    955
    Tom Anderson
    Oct 12, 2010
  4. Bob Hutchison

    Looking for a Fast Persistent Store

    Bob Hutchison, Aug 9, 2006, in forum: Ruby
    Replies:
    43
    Views:
    405
  5. Tony Arcieri
    Replies:
    0
    Views:
    81
    Tony Arcieri
    Dec 7, 2010
Loading...

Share This Page