Sha256: 978181401a0499dba1c95eb70b0e3d5549468bc682151d69e8a4af7df4c12eb1

Contents?: true

Size: 561 Bytes

Versions: 7

Compression:

Stored size: 561 Bytes

Contents

# Aruba
module Aruba
  # Platforms
  module Platforms
    # Local environemnt
    #
    # Wraps logic to make enviroment local and restorable
    class LocalEnvironment
      # Run in environment
      #
      # @param [Hash] env
      #   The environment
      #
      # @yield
      #   The block of code which should with local ENV
      def call(env, &block)
        old_env = ENV.to_hash.dup

        ENV.clear
        ENV.update env

        block.call if block_given?
      ensure
        ENV.clear
        ENV.update old_env
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
aruba-0.13.0 lib/aruba/platforms/local_environment.rb
aruba-0.12.0 lib/aruba/platforms/local_environment.rb
aruba-0.11.2 lib/aruba/platforms/local_environment.rb
aruba-0.11.1 lib/aruba/platforms/local_environment.rb
aruba-0.11.0.pre4 lib/aruba/platforms/local_environment.rb
aruba-0.11.0.pre3 lib/aruba/platforms/local_environment.rb
aruba-0.11.0.pre2 lib/aruba/platforms/local_environment.rb