次のようなルビーブロックを見てきました。
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
モジュールが Vagrant::Config ブロックの外で定義されている場合、エラーが発生します
'<module:Provisioners>': uninitialized constant Vagrant::Provisioners::Chef (NameError)
また、実行ブロック内でモジュールを宣言すると違いが生じる理由がわかりません。