- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: Re: Re: Re: cookbook name as an attribute
- Date: Mon, 2 Dec 2013 09:52:26 -0800
On Monday, December 2, 2013 at 9:44 AM, Tim Cook wrote:
Why am I unable to pass the cookbook as an instance variable to a library class ?
That you can do. In more exact terms:
recipes, attribute files, resource definitions, and LWRP files are all evaluated within a special context. For recipes, this is `instance_eval` of an already initialized `Chef::Recipe` object, which already has the node object, run_context and other stuff populated as instance variables with accessor methods you can use.
library files, on the other hand, are evaluated just by calling ruby’s `Kernel.load` function so they don’t have any of this special context available, so if you need access to the node, run_context or whatever, you have to pass it in from wherever the code gets called.
--
Daniel DeLeo
Archive powered by MHonArc 2.6.16.