class Chef::Node
Slap some dandy handy methods to stick on a node.
Public Instance Methods
get(*keys, &block)
click to toggle source
Recursively searchs a nested datastructure for a key and returns the value. If a block is provided its value will be returned if the key does not exist, otherwise UndefinedAttributeError is raised.
@param [Array<String, Symbol>] keys
The list of keys to kdeep fetch
@yield optional block to execute if no value is found
@raise UndefinedAttributeError
@return [Object]
@api public
# File lib/garcon/chef/node.rb, line 67 def get(*keys, &block) keys.reduce(self) do |obj, key| begin key = Integer(key) if obj.is_a? Array obj.fetch(key) rescue ArgumentError, IndexError, NoMethodError break block.call(key) if block raise UndefinedAttributeError end end end
Also aliased as: deep_fetch
has_recipe?(recipe)
click to toggle source
Boolean
to check if a recipe is loaded in the run list.
@param [String] recipe
the command to find
@return [TrueClass, FalseClass]
true if the command is found in the path, false otherwise
@api public
# File lib/garcon/chef/node.rb, line 35 def has_recipe?(recipe) loaded_recipes.include?(with_default(recipe)) end
Also aliased as: include_recipe?, includes_recipe?
in?(environment)
click to toggle source
Determine if the current node is in the given Chef
environment (or matches the given regular expression).
@param [String, Regex] environment
@return [Boolean]
@api public
# File lib/garcon/chef/node.rb, line 49 def in?(environment) environment === chef_environment end