[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Initialization after YAML load?

Larry Fast

7/25/2007 6:47:00 PM

I'm saving and restoring a large tree structure using YAML. What I've
read is that the Initialize method is not called after loading.

Is there something like a post-load method within YAML that I can
override and is automatically invoked for each object created?

On a slightly related note, I've seen the to_yaml method but I'm looking
for the inverse. I want to save everything unless it's in my not_yaml
list. Does anything like this exist?

Thanks,
Larry Fast
--
Posted via http://www.ruby-....

2 Answers

Jano Svitok

7/25/2007 7:14:00 PM

0

On 7/25/07, Larry Fast <lfast@mdsi.ca> wrote:
> I'm saving and restoring a large tree structure using YAML. What I've
> read is that the Initialize method is not called after loading.
>
> Is there something like a post-load method within YAML that I can
> override and is automatically invoked for each object created?
>
> On a slightly related note, I've seen the to_yaml method but I'm looking
> for the inverse. I want to save everything unless it's in my not_yaml
> list. Does anything like this exist?
>
> Thanks,
> Larry Fast

you can use #to_yaml_properties() - return everything except the ones
you don't want to save. Works on a per attribute basis.

J.

Larry Fast

7/26/2007 3:52:00 AM

0

Jano Svitok wrote:
> you can use #to_yaml_properties() - return everything except the ones
> you don't want to save. Works on a per attribute basis.

Thanks Jano,
That did the trick. As for the postload operations I'm taking a
different route.

--
Posted via http://www.ruby-....