Getting cookbook name from recipe


#1

Hello!
Can you, please, explain me how to get the name of the parent cookbook of
the current running recipe (inside that running recipe)?


Nice day
from Dr. Agon Smith


#2

i think @cookbook_name instance variable holds the name of the current
cookbook inside a recipe.


#3

Yea! Thank you!

2012/5/14 Ranjib Dey ranjibd@thoughtworks.com

i think @cookbook_name instance variable holds the name of the current
cookbook inside a recipe.


Nice day
from Dr. Agon Smith


#4

On Monday, May 14, 2012 at 7:49 AM, Dr. Agon Smith wrote:

Yea! Thank you!

2012/5/14 Ranjib Dey <ranjibd@thoughtworks.com (mailto:ranjibd@thoughtworks.com)>

i think @cookbook_name instance variable holds the name of the current cookbook inside a recipe.

There is also an attribute accessor method for this, which I recommend you use instead.

Because of the way Chef and ruby work, we can’t hide these instance variables from you, but if we need to change the way something works, it’s much more difficult to maintain compatibility if you’re using the instance variables directly. Contrarily, with a method call, we can just change the implementation of the method to return the same result.


Dan DeLeo