Class: VagrantPlugins::ProviderLibvirt::Action::IsRunning

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-libvirt/action/is_running.rb

Overview

This can be used with “Call” built-in to check if the machine is running and branch in the middleware.

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ IsRunning

Returns a new instance of IsRunning.



9
10
11
# File 'lib/vagrant-libvirt/action/is_running.rb', line 9

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

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
# File 'lib/vagrant-libvirt/action/is_running.rb', line 13

def call(env)
  env[:result] = env[:machine].state.id == :running

  @app.call(env)
end