Class: Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue
- Inherits:
-
Object
- Object
- Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue
- Defined in:
- lib/chef/dsl/platform_introspection.rb
Overview
Implementation class for determining platform family dependent values
Instance Method Summary collapse
-
#initialize(platform_family_hash) ⇒ PlatformFamilyDependentValue
constructor
Create a platform family dependent value object.
- #value_for_node(node) ⇒ Object
Constructor Details
#initialize(platform_family_hash) ⇒ PlatformFamilyDependentValue
Create a platform family dependent value object.
Arguments
platform_family_hash (Hash) a map of platform families to values. like this:
{
:rhel => "value for all EL variants"
:fedora => "value for fedora variants fedora and amazon" ,
[:fedora, :rhel] => "value for all known redhat variants"
:debian => "value for debian variants including debian, ubuntu, mint" ,
:default => "the default when nothing else matches"
}
-
platform families can be specified as Symbols or Strings
-
multiple platform families can be grouped by using an Array as the key
-
values for platform families can be any object, with no restrictions. Some examples:
- :stop, :start
-
“mysql-devel”
-
{ :key => “value” }
193 194 195 196 197 |
# File 'lib/chef/dsl/platform_introspection.rb', line 193 def initialize(platform_family_hash) @values = {} @values["default"] = nil platform_family_hash.each { |platform_families, value| set(platform_families, value) } end |
Instance Method Details
#value_for_node(node) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/chef/dsl/platform_introspection.rb', line 199 def value_for_node(node) if node.key?(:platform_family) platform_family = node[:platform_family].to_s if @values.key?(platform_family) @values[platform_family] else @values["default"] end else @values["default"] end end |