Class: Vagrant::Dnsmasq::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-dnsmasq/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



11
12
13
14
15
16
17
18
19
# File 'lib/vagrant-dnsmasq/config.rb', line 11

def initialize
  inc_path = Pathname.new(File.expand_path("../includes", __FILE__))
  require inc_path.join("Domain.class.rb")
  require inc_path.join("Ip.class.rb")

  @enable = UNSET_VALUE
  @domain = UNSET_VALUE
  @ip = UNSET_VALUE
end

Instance Attribute Details

#domainObject

Returns the value of attribute domain.



6
7
8
# File 'lib/vagrant-dnsmasq/config.rb', line 6

def domain
  @domain
end

#enableObject Also known as: enabled?

Returns the value of attribute enable.



5
6
7
# File 'lib/vagrant-dnsmasq/config.rb', line 5

def enable
  @enable
end

#ipObject

Returns the value of attribute ip.



7
8
9
# File 'lib/vagrant-dnsmasq/config.rb', line 7

def ip
  @ip
end

Instance Method Details

#finalize!Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-dnsmasq/config.rb', line 21

def finalize!
  @enable = false if @enable == UNSET_VALUE
  @domain = nil if @domain == UNSET_VALUE
  @ip = nil if @ip == UNSET_VALUE

  # make it a Domain instance
  @domain = Domain.new @domain 
  
  # make it an Ip instance
  @ip = [@ip] unless @ip.kind_of? Array
  @ip.map!{|ip| begin Ip.new(ip) rescue nil end}.compact!

end