# Lazy evaluation

**URL:** <https://discourse.chef.io/t/lazy-evaluation/9258>\
**Category:** Chef Infra (archive)\
**Created:** [August 25, 2016, 7:35pm UTC](https://discourse.chef.io/t/lazy-evaluation/9258 "2016-08-25T19:35:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![liora](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/liora/32/1518_2.png) [@liora](https://discourse.chef.io/u/liora)\
**Post date:** [August 25, 2016, 7:35pm UTC](https://discourse.chef.io/t/lazy-evaluation/9258/1 "2016-08-25T19:35:30Z")

</div>

I have an attribute (node[‘name’]), which value is calculated during execution time (in a ruby\_block).  
I have another ruby\_block which uses the value of the calculated attribute.  
I can’t figure out the correct syntax for the second block. I know I need to use the lazy key word.  
Here is what I have:

ruby\_block “do something” do  
block do  
require 'mixlib/shellout’  
command = "git config xxxx #{node[‘name’]}"  
Mixlib::ShellOut.new(command)  
curl.run\_command  
end  
end

---

<div class="post-metadata">

**Author:** ![Tensibai](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/tensibai/32/29_2.png) [@Tensibai](https://discourse.chef.io/u/Tensibai)\
**Post date:** [August 29, 2016, 1:20pm UTC](https://discourse.chef.io/t/lazy-evaluation/9258/2 "2016-08-29T13:20:54Z")

</div>

Sounds strange, your ruby block should get the updated value (running at converge time), wherever you’re updating the value.

However I wonder if `node['name']` is not an automatic attribute an protected as it is the name used by chef to sign requests.

---

<div class="post-metadata">

**Author:** ![liora](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/liora/32/1518_2.png) [@liora](https://discourse.chef.io/u/liora)\
**Post date:** [August 30, 2016, 8:06am UTC](https://discourse.chef.io/t/lazy-evaluation/9258/3 "2016-08-30T08:06:26Z")

</div>

Right. I have figured it eventually.
