Allow multiple Vagrant::Config.run in a single Vagrantfile again

This commit is contained in:
Mitchell Hashimoto 2011-01-06 19:05:31 -08:00
parent b8c84b67b7
commit a5d8193982
2 changed files with 6 additions and 5 deletions

View File

@ -42,7 +42,8 @@ module Vagrant
# away for execution later. # away for execution later.
def self.run(&block) def self.run(&block)
# Store it for later # Store it for later
@last_proc = block @last_procs ||= []
@last_procs << block
end end
# Returns the last proc which was activated for the class via {run}. This # Returns the last proc which was activated for the class via {run}. This
@ -51,8 +52,8 @@ module Vagrant
# #
# @return [Proc] # @return [Proc]
def self.last_proc def self.last_proc
value = @last_proc value = @last_procs
@last_proc = nil @last_procs = nil
value value
end end
@ -72,7 +73,7 @@ module Vagrant
# and it will never be loaded again. # and it will never be loaded again.
def set(key, path) def set(key, path)
return if @procs.has_key?(key) return if @procs.has_key?(key)
@procs[key] = [path].flatten.map(&method(:proc_for)) @procs[key] = [path].flatten.map(&method(:proc_for)).flatten
end end
# Loads the added procs using the set `load_order` attribute and returns # Loads the added procs using the set `load_order` attribute and returns

View File

@ -11,7 +11,7 @@ class ConfigTest < Test::Unit::TestCase
foo.expects(:call).once foo.expects(:call).once
@klass.run { |config| foo.call } @klass.run { |config| foo.call }
value = @klass.last_proc value = @klass.last_proc.first
assert value.is_a?(Proc) assert value.is_a?(Proc)
value.call value.call