Sha256: 1e99447f438f777c92f10a2ee60e1b86215e9e84f73f1917d564ae41abb51ae4

Contents?: true

Size: 950 Bytes

Versions: 4

Compression:

Stored size: 950 Bytes

Contents

require 'config_builder/model'

module VagrantHosts
  module ConfigBuilder
    class Model < ::ConfigBuilder::Model::Base

      # @!attribute [rw] hosts
      attr_accessor :hosts
      # @!attribute [rw] autoconfigure
      attr_accessor :autoconfigure
      # @!attribute [rw] add_localhost_hostnames
      attr_accessor :add_localhost_hostnames

      def initialize
        @hosts = []
      end

      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

      ::ConfigBuilder::Model::Provisioner.register('hosts', self)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-hosts-2.5.0 lib/vagrant-hosts/config_builder.rb
vagrant-hosts-2.4.0 lib/vagrant-hosts/config_builder.rb
vagrant-hosts-2.3.0 lib/vagrant-hosts/config_builder.rb
vagrant-hosts-2.2.4 lib/vagrant-hosts/config_builder.rb