Sha256: 3f51432effeefab632bad5f9d86770f3fdbd5f3dc98b42e51b0afd879637dbe3

Contents?: true

Size: 1.38 KB

Versions: 61

Compression:

Stored size: 1.38 KB

Contents

module Vagrant
  class Action
    # 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.
    class Environment < Util::HashWithIndifferentAccess
      # The {Vagrant::Environment} object represented by this
      # action environment.
      attr_reader :env

      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

      # Returns a UI object from the environment
      def ui
        env.ui
      end

      # 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 {Action} when
      # a SIGINT is captured.
      def interrupt!
        @interrupted = true
      end

      # Returns a boolean denoting if environment has been interrupted
      # with a SIGINT.
      #
      # @return [Bool]
      def interrupted?
        !!@interrupted
      end
    end
  end
end

Version data entries

61 entries across 61 versions & 5 rubygems

Version Path
vagrantup-0.8.9 lib/vagrant/action/environment.rb
vagrantup-0.8.8 lib/vagrant/action/environment.rb
vagrantup-0.8.7 lib/vagrant/action/environment.rb
vagrantup-0.8.6 lib/vagrant/action/environment.rb
vagrantup-0.8.5 lib/vagrant/action/environment.rb
vagrantup-0.8.4 lib/vagrant/action/environment.rb
vagrantup-0.8.3 lib/vagrant/action/environment.rb
vagrantup-0.8.2 lib/vagrant/action/environment.rb
vagrantup-0.8.10 lib/vagrant/action/environment.rb
vagrantup-0.8.1 lib/vagrant/action/environment.rb
vagrantup-0.8.0 lib/vagrant/action/environment.rb
vagrantup-0.7.8 lib/vagrant/action/environment.rb
vagrantup-0.7.7 lib/vagrant/action/environment.rb
vagrantup-0.7.6 lib/vagrant/action/environment.rb
vagrantup-0.7.5 lib/vagrant/action/environment.rb
vagrantup-0.7.4 lib/vagrant/action/environment.rb
vagrantup-0.7.3 lib/vagrant/action/environment.rb
vagrantup-0.7.2 lib/vagrant/action/environment.rb
vagrantup-0.7.1 lib/vagrant/action/environment.rb
vagrantup-0.7.0 lib/vagrant/action/environment.rb