我見過一個紅寶石塊,看起來像:在模塊中定義的Ruby模塊?
Vagrant::Config.run do |config|
module MyModule
end
end
什麼是宣告像塊裏面一個模塊的影響?
編輯:
具體我有一個塊做一些清理當VM被終止,它看起來像
Vagrant::Config.run do |config|
# vagrant config stuff
module Vagrant
module Provisioners
class ChefClient < Chef
def cleanup
# cleanup here
end
end
end
end
end
如果模塊的流浪::配置塊I之外定義得到錯誤
'<module:Provisioners>': uninitialized constant Vagrant::Provisioners::Chef (NameError)
而我不知道爲什麼在運行塊內聲明模塊有所作爲。
你一般在談論模塊,而不是爲什麼有人會在塊中聲明模塊。 – tadman
那麼,*爲什麼有人這樣做是未知的,所以我們都猜測他們的理由。我們只能建議可能性。爲清楚起見,請致電 –