ruby厨师配方数组&&=conditional

ruby厨师配方数组&&=conditional,ruby,chef-infra,Ruby,Chef Infra,我正在学ruby写厨师烹饪书。我正在看这个食谱 . 我被这个代码块绊倒了 conflicting_recipes.each do |recipe| allow_mongodb_instance_run &&= false if node.run_context.loaded_recipe?(recipe) end 我查阅了&&=的文档,但对我来说没有多大意义。有人能给我解释一下吗。谢谢将表达式展开如下: allow_mongodb_instance_run = allow

我正在学ruby写厨师烹饪书。我正在看这个食谱 . 我被这个代码块绊倒了

conflicting_recipes.each do |recipe| 
  allow_mongodb_instance_run &&= false if node.run_context.loaded_recipe?(recipe)
end

我查阅了&&=的文档,但对我来说没有多大意义。有人能给我解释一下吗。谢谢

将表达式展开如下:

allow_mongodb_instance_run = allow_mongodb_instance_run && false
如果allow_mongodb_instance_run为true而不是false或nil,则它将变为false

如果allow_mongodb_instance_run为false,则它仍为false

如果allow_mongodb_instance_run为nil,它将保持为nil,并且不会变为false


不我不知道为什么有人需要这种区别,但是保留nil是我能想到的唯一好处,只允许\u mongodb\u instance\u run=false。

检查节点是否也设置为在旧的sc mongodb cookbook重新合并之前运行,这是一种有点尴尬的方法,因为两者都会导致冲突,两个cookbook都试图配置/安装相同的事情