Method: Chef::Recipe#from_yaml

Defined in:
lib/chef/recipe.rb

#from_yaml(string) ⇒ Object



95
96
97
98
99
100
101
102
# File 'lib/chef/recipe.rb', line 95

def from_yaml(string)
  res = ::YAML.safe_load(string, permitted_classes: [Date])
  unless res.is_a?(Hash) && res.key?("resources")
    raise ArgumentError, "YAML recipe '#{source_file}' must contain a top-level 'resources' hash (YAML sequence), i.e. 'resources:'"
  end

  from_hash(res)
end