From a5d8193982a18fdd115574ddccf20240850f0396 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 6 Jan 2011 19:05:31 -0800 Subject: [PATCH] Allow multiple Vagrant::Config.run in a single Vagrantfile again --- lib/vagrant/config.rb | 9 +++++---- test/vagrant/config_test.rb | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/config.rb b/lib/vagrant/config.rb index 354eb60c8..6d43c5eb9 100644 --- a/lib/vagrant/config.rb +++ b/lib/vagrant/config.rb @@ -42,7 +42,8 @@ module Vagrant # away for execution later. def self.run(&block) # Store it for later - @last_proc = block + @last_procs ||= [] + @last_procs << block end # Returns the last proc which was activated for the class via {run}. This @@ -51,8 +52,8 @@ module Vagrant # # @return [Proc] def self.last_proc - value = @last_proc - @last_proc = nil + value = @last_procs + @last_procs = nil value end @@ -72,7 +73,7 @@ module Vagrant # and it will never be loaded again. def set(key, path) return if @procs.has_key?(key) - @procs[key] = [path].flatten.map(&method(:proc_for)) + @procs[key] = [path].flatten.map(&method(:proc_for)).flatten end # Loads the added procs using the set `load_order` attribute and returns diff --git a/test/vagrant/config_test.rb b/test/vagrant/config_test.rb index 0db26b8e8..09d00111c 100644 --- a/test/vagrant/config_test.rb +++ b/test/vagrant/config_test.rb @@ -11,7 +11,7 @@ class ConfigTest < Test::Unit::TestCase foo.expects(:call).once @klass.run { |config| foo.call } - value = @klass.last_proc + value = @klass.last_proc.first assert value.is_a?(Proc) value.call