Chef LWRP 引用相关资源

Chef LWRP referencing relative resource

我正在尝试创建一个 LWRP 来扩展超市食谱“webpshere”。

在我的资源文件中,我试图使用在父食谱中找到的基础 class 扩展此 class。

在下面的代码中,'WebsphereBase' 是在父库 'websphere_base' 中定义的。我可以获得有关如何引用它的帮助吗? 谢谢

    #require 'websphere_base'
    module PIWebsphereCookBook
    class WebsphereJbdc < WebsphereBase
    require_relative 'helper'

source of the cookbook中,可以看到WebsphereBaseclass是在WebsphereCookbook模块中定义的。

要从该模块外部引用此 class,您必须命名嵌套,以便 Ruby 能够找到您所引用的 class。对于您的示例,这看起来类似于:

module PIWebsphereCookBook
  class WebsphereJbdc < WebsphereCookbook::WebsphereBase
    require_relative 'helper'
    # ...
  end
end

你不需要要求来自上游食谱的东西,你也不可以(除了我的怪异食谱)。您依赖的食谱的所有库都将在您的库文件 运行.

时加载