Google Cloud Platform environment queries - Class Google::Cloud::Env::Variables (v2.2.2)

Reference documentation and code samples for the Google Cloud Platform environment queries class Google::Cloud::Env::Variables.

Access to system environment variables.

This is a hashlike object that controls access to environment variable data. It supports temporarily changing the data source (i.e. swapping ::ENV out for a different set of data) for mocking.

Inherits

  • Object

Methods

#[]

def [](key) -> String, nil
Aliases

Fetch the given environment variable from the backing data.

Parameter
  • key (String)
Returns
  • (String, nil)

#backing_data

def backing_data() -> Hash{String=>String}

The backing data is a hash or hash-like object that represents the environment variable data. This can either be the actual environment variables object (i.e. ENV) or a substitute hash used for mocking.

Returns
  • (Hash{String=>String})

#backing_data=

def backing_data=(value) -> Hash{String=>String}

The backing data is a hash or hash-like object that represents the environment variable data. This can either be the actual environment variables object (i.e. ENV) or a substitute hash used for mocking.

Parameter
  • value (Hash{String=>String})
Returns
  • (Hash{String=>String})

#get

def get(key) -> String, nil
Alias Of: #[]

Fetch the given environment variable from the backing data.

Parameter
  • key (String)
Returns
  • (String, nil)

#initialize

def initialize() -> Variables

Create an enviroment variables access object. This is initially backed by the actual environment variables (i.e. ENV).

Returns
  • (Variables) — a new instance of Variables

#with_backing_data

def with_backing_data(temp_backing_data)

Run the given block with the backing data replaced with the given hash. The original backing data is restored afterward. This is used for debugging/testing/mocking.

Parameter
  • temp_backing_data (Hash{String=>String})