# Initialization after YAML load?

**URL:** <https://www.ruby-forum.com/t/initialization-after-yaml-load/110368>\
**Category:** Ruby\
**Created:** [July 25, 2007, 8:46pm UTC](https://www.ruby-forum.com/t/initialization-after-yaml-load/110368 "2007-07-25T20:46:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfast](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ee59a6/32.png) [@lfast](https://www.ruby-forum.com/u/lfast)\
**Post date:** [July 25, 2007, 8:46pm UTC](https://www.ruby-forum.com/t/initialization-after-yaml-load/110368/1 "2007-07-25T20:46:27Z")

</div>

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 F.

---

<div class="post-metadata">

**Author:** ![lfast](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ee59a6/32.png) [@lfast](https://www.ruby-forum.com/u/lfast)\
**Post date:** [July 26, 2007, 12:46am UTC](https://www.ruby-forum.com/t/initialization-after-yaml-load/110368/2 "2007-07-26T00:46:14Z")

</div>

On 7/25/07, Larry F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks,  
> Larry F.

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

J.

---

<div class="post-metadata">

**Author:** ![lfast](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/ee59a6/32.png) [@lfast](https://www.ruby-forum.com/u/lfast)\
**Post date:** [July 26, 2007, 5:51am UTC](https://www.ruby-forum.com/t/initialization-after-yaml-load/110368/3 "2007-07-26T05:51:53Z")

</div>

Jano S. 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.
