Class: VagrantHosts::ConfigBuilder::Model

Inherits:
ConfigBuilder::Model::Base
  • Object
show all
Defined in:
lib/vagrant-hosts/config_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeModel

Returns a new instance of Model.



14
15
16
# File 'lib/vagrant-hosts/config_builder.rb', line 14

def initialize
  @hosts = []
end

Instance Attribute Details

#add_localhost_hostnamesObject



12
13
14
# File 'lib/vagrant-hosts/config_builder.rb', line 12

def add_localhost_hostnames
  @add_localhost_hostnames
end

#autoconfigureObject



10
11
12
# File 'lib/vagrant-hosts/config_builder.rb', line 10

def autoconfigure
  @autoconfigure
end

#hostsObject



8
9
10
# File 'lib/vagrant-hosts/config_builder.rb', line 8

def hosts
  @hosts
end

Instance Method Details

#to_procObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vagrant-hosts/config_builder.rb', line 18

def to_proc
  Proc.new do |vm_config|
    vm_config.provision :hosts do |h_config|
      h_config.autoconfigure = attr(:autoconfigure) unless attr(:autoconfigure).nil?
      h_config.add_localhost_hostnames = attr(:add_localhost_hostnames) unless attr(:add_localhost_hostnames).nil?

      @hosts.each do |(address, aliases)|
        h_config.add_host address, aliases
      end
    end
  end
end