我正在尝试使用Chef属性动态创建一个 Ruby 模板,但是我无法弄清如何将属性映射到所需的输出方式。
示例哈希:
a = {
"route" => {
"allocation" => {
"recovery" => {
"speed" => 5,
"timeout" => "30s"
},
"converge" => {
"timeout" => "1m"
}
}
}
}
Would turn into:
route.allocation.recovery.speed: 5
route.allocation.recovery.timeout: 30s
route.allocation.converge.timeout: 1m
感谢您的帮助。
if v.is_a? Hash
代替if v.respond_to?
是否更好? - jarsever