class Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue
Implementation class for determining platform family dependent values
Public Class Methods
new(platform_family_hash)
click to toggle source
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” }
# File lib/chef/dsl/platform_introspection.rb, line 187 def initialize(platform_family_hash) @values = {} @values["default"] = nil platform_family_hash.each { |platform_families, value| set(platform_families, value) } end
Public Instance Methods
value_for_node(node)
click to toggle source
# File lib/chef/dsl/platform_introspection.rb, line 193 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
Private Instance Methods
set(platform_family, value)
click to toggle source
# File lib/chef/dsl/platform_introspection.rb, line 208 def set(platform_family, value) if platform_family.to_s == "default" @values["default"] = value else Array(platform_family).each { |family| @values[family.to_s] = value } value end end