Class: VagrantPlugins::Skytap::Action::ExistenceCheck
- Includes:
- ActionHelpers
- Defined in:
- lib/vagrant-skytap/action/existence_check.rb
Overview
This can be used with “Call” built-in to check if the environment is created and branch in the middleware.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ExistenceCheck
constructor
A new instance of ExistenceCheck.
Methods included from ActionHelpers
Constructor Details
#initialize(app, env) ⇒ ExistenceCheck
Returns a new instance of ExistenceCheck.
34 35 36 37 |
# File 'lib/vagrant-skytap/action/existence_check.rb', line 34 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_skytap::action::existence_check") end |
Instance Method Details
#call(env) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/vagrant-skytap/action/existence_check.rb', line 39 def call(env) environment = env[:environment] env[:result] = if !environment :missing_environment elsif environment.vms.count == 0 :no_vms elsif !current_vm(env) # Could be confusing. The *current* vm is not present. This response also implies that there are other vms. :missing_vm elsif environment.vms.count == 1 :solitary_vm else :one_of_many_vms end @logger.debug("ExistenceCheck returning #{env[:result]}") @app.call(env) end |