如何从厨师食谱中调用REXML :: Element :: add_attributes?

时间:2016-10-20 22:12:09

标签: chef chef-recipe

我有一些'厨师!=红宝石'问题。我有一些XML代码似乎在irbpry中正常工作,但在主厨中失败

NoMethodError
-------------
undefined method `add_attribute'

错误。

require "rexml/document"
::Chef::Recipe.send(:include, REXML) # can't `include REXML`
updates = Document.new(File.new updates_file)
options = updates.elements.each('application/component/option[@name="CHECK_NEEDED"]/@value') {|e| e}
unless options.empty?
  # Set existing <option /> Element
  element = options[0]
#  element.add_attribute("value", "false")
#  element.add_attribute( Attribute.new("value", "false") )
#  element.send("add_attribute", "value", "false")
  element.send("add_attribute", Attribute.new("value", "false"))

如何让这个食谱“编译”?

0 个答案:

没有答案