Get rid of the UNSET_VALUE stuff, save it for v2

This commit is contained in:
Mitchell Hashimoto 2012-04-18 17:09:25 -07:00
parent b38fb5e974
commit a62e859231
5 changed files with 2 additions and 37 deletions

View File

@ -5,11 +5,6 @@ module Vagrant
# from this class but this class provides useful helpers that config
# classes may wish to use.
class Base
# This is a useful default to use for attributes, and the built-in
# merge for this class will use this as a marker that a value is
# unset (versus just being explicitly set to `nil`)
UNSET_VALUE = Object.new
# Merge another configuration object into this one. This assumes that
# the other object is the same class as this one.
#

View File

@ -5,11 +5,6 @@ module VagrantPlugins
class NFSConfig < Vagrant::Config::V1::Base
attr_accessor :map_uid
attr_accessor :map_gid
def initialize
@map_uid = UNSET_VALUE
@map_gid = UNSET_VALUE
end
end
end
end

View File

@ -4,10 +4,6 @@ module VagrantPlugins
module Kernel
class PackageConfig < Vagrant::Config::V1::Base
attr_accessor :name
def initialize
@name = UNSET_VALUE
end
end
end
end

View File

@ -15,29 +15,13 @@ module VagrantPlugins
attr_accessor :forward_x11
attr_accessor :shell
def initialize
@username = UNSET_VALUE
@password = UNSET_VALUE
@host = UNSET_VALUE
@port = UNSET_VALUE
@guest_port = UNSET_VALUE
@max_tries = UNSET_VALUE
@timeout = UNSET_VALUE
@private_key_path = UNSET_VALUE
@forward_agent = UNSET_VALUE
@forward_x11 = UNSET_VALUE
@shell = UNSET_VALUE
end
def validate(env, errors)
[:username, :host, :max_tries, :timeout].each do |field|
value = instance_variable_get("@#{field}".to_sym)
if value == UNSET_VALUE || !value
errors.add(I18n.t("vagrant.config.common.error_empty", :field => field))
end
errors.add(I18n.t("vagrant.config.common.error_empty", :field => field)) if !value
end
if private_key_path && private_key_path != UNSET_VALUE && !File.file?(File.expand_path(private_key_path, env.root_path))
if private_key_path && !File.file?(File.expand_path(private_key_path, env.root_path))
errors.add(I18n.t("vagrant.config.ssh.private_key_missing", :path => private_key_path))
end
end

View File

@ -5,11 +5,6 @@ module VagrantPlugins
class VagrantConfig < Vagrant::Config::V1::Base
attr_accessor :dotfile_name
attr_accessor :host
def initialize
@dotfile_name = UNSET_VALUE
@host = UNSET_VALUE
end
end
end
end