Class: Chef::Recipe
- Includes:
- Mixin::FromFile, Mixin::Language, Mixin::LanguageIncludeRecipe, Mixin::RecipeDefinitionDSLCore
- Defined in:
- lib/chef/recipe.rb,
lib/chef/shef/ext.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#cookbook_loader ⇒ Object
Returns the value of attribute cookbook_loader.
-
#cookbook_name ⇒ Object
Returns the value of attribute cookbook_name.
-
#definitions ⇒ Object
Returns the value of attribute definitions.
-
#node ⇒ Object
Returns the value of attribute node.
-
#params ⇒ Object
Returns the value of attribute params.
-
#recipe ⇒ Object
Returns the value of attribute recipe.
-
#recipe_name ⇒ Object
Returns the value of attribute recipe_name.
Instance Method Summary collapse
-
#initialize(cookbook_name, recipe_name, node, collection = nil, definitions = nil, cookbook_loader = nil) ⇒ Recipe
constructor
A new instance of Recipe.
- #original_resources ⇒ Object
- #resources(*args) ⇒ Object
- #shef_help ⇒ Object
-
#tag(*args) ⇒ Object
Sets a tag, or list of tags, for this node.
-
#tagged?(*args) ⇒ Boolean
Returns true if the node is tagged with the supplied list of tags.
-
#untag(*args) ⇒ Object
Removes the list of tags from the node.
Methods included from Mixin::RecipeDefinitionDSLCore
Methods included from Mixin::Language
#data_bag, #data_bag_item, #platform?, #search, #value_for_platform
Methods included from Mixin::ConvertToClassName
#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string
Methods included from Mixin::LanguageIncludeRecipe
#include_recipe, #require_recipe
Methods included from Mixin::FromFile
Constructor Details
#initialize(cookbook_name, recipe_name, node, collection = nil, definitions = nil, cookbook_loader = nil) ⇒ Recipe
Returns a new instance of Recipe.
41 42 43 44 45 46 47 48 49 |
# File 'lib/chef/recipe.rb', line 41 def initialize(cookbook_name, recipe_name, node, collection=nil, definitions=nil, cookbook_loader=nil) @cookbook_name = cookbook_name @recipe_name = recipe_name @node = node @collection = collection || Chef::ResourceCollection.new @definitions = definitions || Hash.new @cookbook_loader = cookbook_loader || Chef::CookbookLoader.new @params = Hash.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Chef::Mixin::RecipeDefinitionDSLCore
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
38 39 40 |
# File 'lib/chef/recipe.rb', line 38 def collection @collection end |
#cookbook_loader ⇒ Object
Returns the value of attribute cookbook_loader.
38 39 40 |
# File 'lib/chef/recipe.rb', line 38 def cookbook_loader @cookbook_loader end |
#cookbook_name ⇒ Object
Returns the value of attribute cookbook_name.
38 39 40 |
# File 'lib/chef/recipe.rb', line 38 def cookbook_name @cookbook_name end |
#definitions ⇒ Object
Returns the value of attribute definitions.
38 39 40 |
# File 'lib/chef/recipe.rb', line 38 def definitions @definitions end |
#node ⇒ Object
Returns the value of attribute node.
38 39 40 |
# File 'lib/chef/recipe.rb', line 38 def node @node end |
#params ⇒ Object
Returns the value of attribute params.
38 39 40 |
# File 'lib/chef/recipe.rb', line 38 def params @params end |
#recipe ⇒ Object
Returns the value of attribute recipe.
38 39 40 |
# File 'lib/chef/recipe.rb', line 38 def recipe @recipe end |
#recipe_name ⇒ Object
Returns the value of attribute recipe_name.
38 39 40 |
# File 'lib/chef/recipe.rb', line 38 def recipe_name @recipe_name end |
Instance Method Details
#original_resources ⇒ Object
285 286 287 |
# File 'lib/chef/shef/ext.rb', line 285 def resources(*args) @collection.resources(*args) end |
#resources(*args) ⇒ Object
51 52 53 |
# File 'lib/chef/recipe.rb', line 51 def resources(*args) @collection.resources(*args) end |
#shef_help ⇒ Object
281 282 283 |
# File 'lib/chef/shef/ext.rb', line 281 def shef_help super("Help: Shef/Recipe") end |
#tag(*args) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/chef/recipe.rb', line 65 def tag(*args) if args.length > 0 args.each do |tag| @node[:tags] << tag unless @node[:tags].include?(tag) end @node[:tags] else @node[:tags] end end |
#tagged?(*args) ⇒ Boolean
Returns true if the node is tagged with the supplied list of tags.
Parameters
- tags<Array>
-
A list of tags
Returns
- true<TrueClass>
-
If all the parameters are present
- false<FalseClass>
-
If any of the parameters are missing
84 85 86 87 88 89 |
# File 'lib/chef/recipe.rb', line 84 def tagged?(*args) args.each do |tag| return false unless @node[:tags].include?(tag) end true end |