Class: Vagrant::Action::Environment
- Inherits:
-
Util::HashWithIndifferentAccess
- Object
- Hash
- Util::HashWithIndifferentAccess
- Vagrant::Action::Environment
- Defined in:
- lib/vagrant/action/environment.rb
Overview
Represents an action environment which is what is passed
to the call
method of each action. This environment contains
some helper methods for accessing the environment as well
as being a hash, to store any additional options.
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
The Environment object represented by this action environment.
Instance Method Summary collapse
-
#initialize(env) ⇒ Environment
constructor
A new instance of Environment.
-
#interrupt! ⇒ Object
Marks an environment as interrupted (by an outside signal or anything).
-
#interrupted? ⇒ Bool
Returns a boolean denoting if environment has been interrupted with a SIGINT.
-
#ui ⇒ Object
Returns a UI object from the environment.
Methods inherited from Util::HashWithIndifferentAccess
#[], #[]=, #delete, #key?, #merge, #merge!, #values_at
Constructor Details
#initialize(env) ⇒ Environment
Returns a new instance of Environment.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vagrant/action/environment.rb', line 12 def initialize(env) super() do |h,k| # By default, try to find the key as a method on the # environment. Gross eval use here. begin value = eval("h.env.#{k}") h[k] = value rescue Exception nil end end @env = env @interrupted = false end |
Instance Attribute Details
#env ⇒ Object (readonly)
The Environment object represented by this action environment.
10 11 12 |
# File 'lib/vagrant/action/environment.rb', line 10 def env @env end |
Instance Method Details
#interrupt! ⇒ Object
Marks an environment as interrupted (by an outside signal or anything). This will trigger any middleware sequences using this environment to halt. This is automatically set by Vagrant::Action when a SIGINT is captured.
37 38 39 |
# File 'lib/vagrant/action/environment.rb', line 37 def interrupt! @interrupted = true end |
#interrupted? ⇒ Bool
Returns a boolean denoting if environment has been interrupted with a SIGINT.
45 46 47 |
# File 'lib/vagrant/action/environment.rb', line 45 def interrupted? !!@interrupted end |
#ui ⇒ Object
Returns a UI object from the environment
29 30 31 |
# File 'lib/vagrant/action/environment.rb', line 29 def ui env.ui end |