Class: VagrantHosts::Cap::SyncHosts::Base

Inherits:
Object
  • Object
show all
Includes:
Addresses
Defined in:
lib/vagrant-hosts/cap/sync_hosts/base.rb

Overview

Provide an abstract base class for syncing hosts entries

Direct Known Subclasses

POSIX, Windows

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(machine, config) ⇒ Base

Returns a new instance of Base.



11
12
13
14
# File 'lib/vagrant-hosts/cap/sync_hosts/base.rb', line 11

def initialize(machine, config)
  @machine, @config = machine, config
  @env = @machine.env
end

Class Method Details

.sync_hosts(machine, config) ⇒ Object



7
8
9
# File 'lib/vagrant-hosts/cap/sync_hosts/base.rb', line 7

def self.sync_hosts(machine, config)
  new(machine, config).sync!
end

Instance Method Details

#sync!Object



16
17
18
19
20
21
22
# File 'lib/vagrant-hosts/cap/sync_hosts/base.rb', line 16

def sync!
  hostname = @machine.config.vm.hostname || @machine.name.to_s
  change_host_name(hostname)

  # call to method not implemented by abstract base class
  update_hosts
end