Class: VagrantPlugins::HostManager::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::HostManager::Config
- Defined in:
- lib/vagrant-hostmanager-rethinc/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_guest ⇒ Object
(also: #manage_guest?)
Returns the value of attribute manage_guest.
-
#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.
17 18 19 20 21 22 23 24 25 |
# File 'lib/vagrant-hostmanager-rethinc/config.rb', line 17 def initialize @enabled = UNSET_VALUE @manage_host = UNSET_VALUE @manage_guest = 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.
8 9 10 |
# File 'lib/vagrant-hostmanager-rethinc/config.rb', line 8 def aliases @aliases end |
#enabled ⇒ Object Also known as: enabled?
Returns the value of attribute enabled.
4 5 6 |
# File 'lib/vagrant-hostmanager-rethinc/config.rb', line 4 def enabled @enabled end |
#ignore_private_ip ⇒ Object
Returns the value of attribute ignore_private_ip.
7 8 9 |
# File 'lib/vagrant-hostmanager-rethinc/config.rb', line 7 def ignore_private_ip @ignore_private_ip end |
#include_offline ⇒ Object Also known as: include_offline?
Returns the value of attribute include_offline.
9 10 11 |
# File 'lib/vagrant-hostmanager-rethinc/config.rb', line 9 def include_offline @include_offline end |
#ip_resolver ⇒ Object
Returns the value of attribute ip_resolver.
10 11 12 |
# File 'lib/vagrant-hostmanager-rethinc/config.rb', line 10 def ip_resolver @ip_resolver end |
#manage_guest ⇒ Object Also known as: manage_guest?
Returns the value of attribute manage_guest.
6 7 8 |
# File 'lib/vagrant-hostmanager-rethinc/config.rb', line 6 def manage_guest @manage_guest end |
#manage_host ⇒ Object Also known as: manage_host?
Returns the value of attribute manage_host.
5 6 7 |
# File 'lib/vagrant-hostmanager-rethinc/config.rb', line 5 def manage_host @manage_host end |
Instance Method Details
#finalize! ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/vagrant-hostmanager-rethinc/config.rb', line 27 def finalize! @enabled = false if @enabled == UNSET_VALUE @manage_host = false if @manage_host == UNSET_VALUE @manage_guest = true if @manage_guest == 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
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 64 65 66 67 68 |
# File 'lib/vagrant-hostmanager-rethinc/config.rb', line 39 def validate(machine) errors = [] errors << validate_bool('hostmanager.enabled', @enabled) errors << validate_bool('hostmanager.manage_host', @manage_host) errors << validate_bool('hostmanager.manage_guest', @manage_guest) 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 |