Class: Vagrant::Action::Builtin::Confirm
- Inherits:
-
Object
- Object
- Vagrant::Action::Builtin::Confirm
- Defined in:
- lib/vagrant/action/builtin/confirm.rb
Overview
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env, message, force_key = nil) ⇒ Confirm
constructor
For documentation, read the description of the Confirm class.
Constructor Details
#initialize(app, env, message, force_key = nil) ⇒ Confirm
For documentation, read the description of the Vagrant::Action::Builtin::Confirm class.
14 15 16 17 18 |
# File 'lib/vagrant/action/builtin/confirm.rb', line 14 def initialize(app, env, , force_key=nil) @app = app @message = @force_key = force_key end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant/action/builtin/confirm.rb', line 20 def call(env) choice = nil # If we have a force key set and we're forcing, then set # the result to "Y" choice = "Y" if @force_key && env[@force_key] # If we haven't chosen yes, then ask the user via TTY choice = env[:ui].ask(@message) if !choice # The result is only true if the user said "Y" env[:result] = choice && choice.upcase == "Y" @app.call(env) end |