Class: VagrantPlugins::MultiHostsUpdater::Action::RemoveHosts

Inherits:
Object
  • Object
show all
Includes:
MultiHostsUpdater
Defined in:
lib/vagrant-multi-hostsupdater/Action/RemoveHosts.rb

Instance Method Summary collapse

Methods included from MultiHostsUpdater

#addHostEntries, #addToHosts, #cacheHostEntries, #getHostEntries, #getHostnames, #getIps, #host_entry, #removeFromHosts, #removeHostEntries, #signature, #sudo

Constructor Details

#initialize(app, env) ⇒ RemoveHosts

Returns a new instance of RemoveHosts.



7
8
9
10
11
# File 'lib/vagrant-multi-hostsupdater/Action/RemoveHosts.rb', line 7

def initialize(app, env)
  @app = app
  @machine = env[:machine]
  @ui = env[:ui]
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant-multi-hostsupdater/Action/RemoveHosts.rb', line 13

def call(env)
  machine_action = env[:machine_action]
  if machine_action != :destroy || !@machine.id
    if machine_action != :suspend || @machine.config.multihostsupdater.remove_on_suspend
      @ui.info "Removing hosts"
      removeHostEntries
    else
      @ui.info "Removing hosts on suspend disabled"
    end
  end
  @app.call(env)
end