Class: Vagrant::Action::VM::DiscardState

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/action/vm/discard_state.rb

Overview

Discards the saved state of the VM if its saved. If its not saved, does nothing.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ DiscardState

Returns a new instance of DiscardState.



7
8
9
# File 'lib/vagrant/action/vm/discard_state.rb', line 7

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/vagrant/action/vm/discard_state.rb', line 11

def call(env)
  if env[:vm].state == :saved
    env[:ui].info I18n.t("vagrant.actions.vm.discard_state.discarding")
    env[:vm].driver.discard_saved_state
  end

  @app.call(env)
end