class VagrantHosts::ConfigBuilder::Model

Attributes

add_localhost_hostnames[RW]

@!attribute [rw] add_localhost_hostnames

autoconfigure[RW]

@!attribute [rw] autoconfigure

hosts[RW]

@!attribute [rw] hosts

sync_hosts[RW]

@!attribute [rw] sync_hosts

Public Class Methods

new() click to toggle source
# File lib/vagrant-hosts/config_builder/0_x.rb, line 17
def initialize
  @defaults = {
    :hosts => [],
  }
end

Public Instance Methods

configure_exports(config, val) click to toggle source

@private

# File lib/vagrant-hosts/config_builder/1_x.rb, line 26
def configure_exports(config, val)
  val.each do |k, v|
    config.exports[k] ||= []
    config.exports[k] += v
  end
end
configure_hosts(config, val) click to toggle source

@private

# File lib/vagrant-hosts/config_builder/1_x.rb, line 40
def configure_hosts(config, val)
  val.each do |(address, aliases)|
    config.add_host(address, aliases)
  end
end
configure_imports(config, val) click to toggle source

@private

# File lib/vagrant-hosts/config_builder/1_x.rb, line 34
def configure_imports(config, val)
  config.imports += val
  config.imports.uniq!
end
to_proc() click to toggle source
# File lib/vagrant-hosts/config_builder/0_x.rb, line 23
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?
      h_config.sync_hosts = attr(:sync_hosts) unless attr(:sync_hosts).nil?

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