Class: VagrantPlugins::HostManager::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::HostManager::Config
- Defined in:
- lib/vagrant-hostmanager/config.rb
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Returns the value of attribute aliases.
-
#enabled ⇒ Object
(also: #enabled?)
Returns the value of attribute enabled.
-
#ignore_private_ip ⇒ Object
Returns the value of attribute ignore_private_ip.
-
#include_offline ⇒ Object
(also: #include_offline?)
Returns the value of attribute include_offline.
-
#ip_resolver ⇒ Object
Returns the value of attribute ip_resolver.
-
#manage_host ⇒ Object
(also: #manage_host?)
Returns the value of attribute manage_host.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
15 16 17 18 19 20 21 22 |
# File 'lib/vagrant-hostmanager/config.rb', line 15 def initialize @enabled = UNSET_VALUE @manage_host = UNSET_VALUE @ignore_private_ip = UNSET_VALUE @include_offline = UNSET_VALUE @aliases = UNSET_VALUE @ip_resolver = UNSET_VALUE end |
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
7 8 9 |
# File 'lib/vagrant-hostmanager/config.rb', line 7 def aliases @aliases end |
#enabled ⇒ Object Also known as: enabled?
Returns the value of attribute enabled.
4 5 6 |
# File 'lib/vagrant-hostmanager/config.rb', line 4 def enabled @enabled end |
#ignore_private_ip ⇒ Object
Returns the value of attribute ignore_private_ip.
6 7 8 |
# File 'lib/vagrant-hostmanager/config.rb', line 6 def ignore_private_ip @ignore_private_ip end |
#include_offline ⇒ Object Also known as: include_offline?
Returns the value of attribute include_offline.
8 9 10 |
# File 'lib/vagrant-hostmanager/config.rb', line 8 def include_offline @include_offline end |
#ip_resolver ⇒ Object
Returns the value of attribute ip_resolver.
9 10 11 |
# File 'lib/vagrant-hostmanager/config.rb', line 9 def ip_resolver @ip_resolver end |
#manage_host ⇒ Object Also known as: manage_host?
Returns the value of attribute manage_host.
5 6 7 |
# File 'lib/vagrant-hostmanager/config.rb', line 5 def manage_host @manage_host end |
Instance Method Details
#finalize! ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vagrant-hostmanager/config.rb', line 24 def finalize! @enabled = false if @enabled == UNSET_VALUE @manage_host = false if @manage_host == UNSET_VALUE @ignore_private_ip = false if @ignore_private_ip == UNSET_VALUE @include_offline = false if @include_offline == UNSET_VALUE @aliases = [] if @aliases == UNSET_VALUE @ip_resolver = nil if @ip_resolver == UNSET_VALUE @aliases = [ @aliases ].flatten end |
#validate(machine) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/vagrant-hostmanager/config.rb', line 35 def validate(machine) errors = [] errors << validate_bool('hostmanager.enabled', @enabled) errors << validate_bool('hostmanager.manage_host', @manage_host) errors << validate_bool('hostmanager.ignore_private_ip', @ignore_private_ip) errors << validate_bool('hostmanager.include_offline', @include_offline) errors.compact! # check if aliases option is an Array if !machine.config.hostmanager.aliases.kind_of?(Array) && !machine.config.hostmanager.aliases.kind_of?(String) errors << I18n.t('vagrant_hostmanager.config.not_an_array_or_string', { :config_key => 'hostmanager.aliases', :is_class => aliases.class.to_s, }) end if !machine.config.hostmanager.ip_resolver.nil? && !machine.config.hostmanager.ip_resolver.kind_of?(Proc) errors << I18n.t('vagrant_hostmanager.config.not_a_proc', { :config_key => 'hostmanager.ip_resolver', :is_class => ip_resolver.class.to_s, }) end errors.compact! { "HostManager configuration" => errors } end |