Class: VagrantPlugins::VirtualHostsUpdater::Action::RemoveHosts

Inherits:
BaseAction
  • Object
show all
Defined in:
lib/vagrant-virtual-hostsupdater/Action/RemoveHosts.rb

Instance Method Summary collapse

Methods inherited from BaseAction

#call, #initialize

Methods included from VirtualHostsUpdater

#addHostEntries, #addToHosts, #adviseOnSudo, #cacheHostEntries, #createHostEntry, #getHostnames, #hostEntryPattern, #host_entry, #removeFromHosts, #removeHostEntries, #signature, #sudo

Constructor Details

This class inherits a constructor from VagrantPlugins::VirtualHostsUpdater::Action::BaseAction

Instance Method Details

#run(env) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/vagrant-virtual-hostsupdater/Action/RemoveHosts.rb', line 6

def run(env)
  machine_action = env[:machine_action]
  if [:suspend, :halt].include? machine_action
    if @machine.config.virtualhostsupdater.remove_on_suspend == false
      @ui.info "[vagrant-virtual-hostsupdater] Not removing hosts (remove_on_suspend false)"
    else
      @ui.info "[vagrant-virtual-hostsupdater] Removing hosts on suspend"
      removeHostEntries
    end
  else
    @ui.info "[vagrant-virtual-hostsupdater] Removing hosts"
    removeHostEntries
  end
end