Module: Chef::Mixin::Language
- Included in:
- RecipeDefinitionDSLCore, Recipe, Resource
- Defined in:
- lib/chef/mixin/language.rb
Defined Under Namespace
Classes: PlatformDependentValue
Instance Method Summary collapse
-
#platform?(*args) ⇒ Boolean
Given a list of platforms, returns true if the current recipe is being run on a node with that platform, false otherwise.
-
#value_for_platform(platform_hash) ⇒ Object
Given a hash similar to the one we use for Platforms, select a value from the hash.
Instance Method Details
#platform?(*args) ⇒ Boolean
Given a list of platforms, returns true if the current recipe is being run on a node with that platform, false otherwise.
Parameters
- args
-
A list of platforms
Returns
- true
-
If the current platform is in the list
- false
-
If the current platform is not in the list
113 114 115 116 117 118 119 120 121 |
# File 'lib/chef/mixin/language.rb', line 113 def platform?(*args) has_platform = false args.flatten.each do |platform| has_platform = true if platform == node[:platform] end has_platform end |
#value_for_platform(platform_hash) ⇒ Object
Given a hash similar to the one we use for Platforms, select a value from the hash. Supports per platform defaults, along with a single base default. Arrays may be passed as hash keys and will be expanded.
Parameters
- platform_hash
-
A platform-style hash.
Returns
- value
-
Whatever the most specific value of the hash is.
100 101 102 |
# File 'lib/chef/mixin/language.rb', line 100 def value_for_platform(platform_hash) PlatformDependentValue.new(platform_hash).value_for_node(node) end |