Just some comments

This commit is contained in:
Mitchell Hashimoto 2012-11-07 22:21:48 -08:00
parent 2ef6ff10f0
commit b416665fd7
1 changed files with 5 additions and 0 deletions

View File

@ -138,6 +138,8 @@ module Vagrant
# backed by. # backed by.
# @return [Machine] # @return [Machine]
def machine(name, provider) def machine(name, provider)
# Compose the cache key of the name and provider, and return from
# the cache if we have that.
cache_key = [name, provider] cache_key = [name, provider]
@machines ||= {} @machines ||= {}
return @machines[cache_key] if @machines.has_key?(cache_key) return @machines[cache_key] if @machines.has_key?(cache_key)
@ -153,6 +155,9 @@ module Vagrant
end end
box = boxes.find(vm_config.vm.box, provider) box = boxes.find(vm_config.vm.box, provider)
# Create the machine and cache it for future calls. This will also
# return the machine from this method.
@machines[cache_key] = Machine.new(name, provider_cls, vm_config, box, self) @machines[cache_key] = Machine.new(name, provider_cls, vm_config, box, self)
end end