我有一些'厨师!=红宝石'问题。我有一些XML代码似乎在irb
和pry
中正常工作,但在主厨中失败
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"))
如何让这个食谱“编译”?