# Preserve value between definitions call?

**URL:** <https://discourse.chef.io/t/preserve-value-between-definitions-call/4038>\
**Category:** Chef Infra (archive)\
**Created:** [May 30, 2013, 4:14pm UTC](https://discourse.chef.io/t/preserve-value-between-definitions-call/4038 "2013-05-30T16:14:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dennybaa](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dennybaa/32/286_2.png) [@dennybaa](https://discourse.chef.io/u/dennybaa)\
**Post date:** [May 30, 2013, 4:14pm UTC](https://discourse.chef.io/t/preserve-value-between-definitions-call/4038/1 "2013-05-30T16:14:13Z")

</div>

Hello chefs,

I was really surprised to find out that when the same definition is  
called one after one in the same recipe the recipe instance is different!  
How is it possible? This messes up my understanding of chef again) The  
more I work with chef the more interesting moments I constantly find out)

I was trying to save a value as an instance variable of recipe, but it’s  
occured that those were different recipe instances. So it seems like  
chef duplicates recipe instance when executing definition and probably  
resource. Is it true?

Do you see any clean ruby way to preserve a value between definition calls?

Thank you,  
Denis Barishev
