Class: VagrantAutoDNS::Config
- Inherits:
-
Object
- Object
- VagrantAutoDNS::Config
- Defined in:
- lib/vagrant-autodns/config.rb
Constant Summary collapse
- DAEMON_DEFAULT_OPTS =
{ :working_directory => '.vagrant/autodns', :listen_ip => '127.0.0.1', :listen_port => 15353, :resolver => :system, #Deamon defaults to system :db_file => 'autodns.db', :enable_ipv6 => true, }
- CLIENT_DEFAULT_OPTS =
{ :aliases => [] }
- DEFAULT_VALUES =
{ :enabled => false }.merge(DAEMON_DEFAULT_OPTS).merge(CLIENT_DEFAULT_OPTS)
Instance Attribute Summary collapse
-
#db_file ⇒ String
DB File name.
-
#enable_ipv6 ⇒ Boolean
Enable ipv6.
- #enabled ⇒ Boolean
-
#listen_ip ⇒ String
Valid IPV4 address (default 127.0.0.1).
-
#listen_ipv6 ⇒ String
IPv6 address.
-
#listen_port ⇒ Fixnum
Port number (default 15353).
-
#resolver ⇒ String, Array
(default System resolver).
-
#working_directory ⇒ String
Directory to store data and state.
Instance Method Summary collapse
- #alias(*aliases) ⇒ Object
- #disable ⇒ Object
- #enable ⇒ Object
- #enabled? ⇒ Boolean
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
56 57 58 59 60 61 62 |
# File 'lib/vagrant-autodns/config.rb', line 56 def initialize super DEFAULT_VALUES.keys.each do |default_key| instance_key = instance_var(default_key) instance_variable_set(instance_key, UNSET_VALUE) end end |
Instance Attribute Details
#db_file ⇒ String
Returns DB File name.
37 38 39 |
# File 'lib/vagrant-autodns/config.rb', line 37 def db_file @db_file end |
#enable_ipv6 ⇒ Boolean
Returns Enable ipv6.
31 32 33 |
# File 'lib/vagrant-autodns/config.rb', line 31 def enable_ipv6 @enable_ipv6 end |
#enabled ⇒ Boolean
16 17 18 |
# File 'lib/vagrant-autodns/config.rb', line 16 def enabled @enabled end |
#listen_ip ⇒ String
Returns Valid IPV4 address (default 127.0.0.1).
22 23 24 |
# File 'lib/vagrant-autodns/config.rb', line 22 def listen_ip @listen_ip end |
#listen_ipv6 ⇒ String
Returns IPv6 address.
28 29 30 |
# File 'lib/vagrant-autodns/config.rb', line 28 def listen_ipv6 @listen_ipv6 end |
#listen_port ⇒ Fixnum
Returns Port number (default 15353).
25 26 27 |
# File 'lib/vagrant-autodns/config.rb', line 25 def listen_port @listen_port end |
#resolver ⇒ String, Array
Returns (default System resolver).
19 20 21 |
# File 'lib/vagrant-autodns/config.rb', line 19 def resolver @resolver end |
#working_directory ⇒ String
Returns Directory to store data and state.
34 35 36 |
# File 'lib/vagrant-autodns/config.rb', line 34 def working_directory @working_directory end |
Instance Method Details
#alias(*aliases) ⇒ Object
64 65 66 |
# File 'lib/vagrant-autodns/config.rb', line 64 def alias(*aliases) @aliases.concat(aliases) end |
#disable ⇒ Object
72 73 74 |
# File 'lib/vagrant-autodns/config.rb', line 72 def disable @enabled = false end |
#enable ⇒ Object
68 69 70 |
# File 'lib/vagrant-autodns/config.rb', line 68 def enable @enabled = true end |
#enabled? ⇒ Boolean
76 77 78 79 |
# File 'lib/vagrant-autodns/config.rb', line 76 def enabled? #Coerce to boolean !!@enabled end |
#finalize! ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/vagrant-autodns/config.rb', line 81 def finalize! #special handling for working_directory DEFAULT_VALUES.each do |default_key, default_value| instance_key = instance_var(default_key) if instance_variable_get(instance_key) == UNSET_VALUE instance_variable_set(instance_key, default_value) end next unless DAEMON_DEFAULT_OPTS.has_key?(default_key) Daemon.send(:instance_variable_set, instance_key, instance_variable_get(instance_key)) end end |