Module: HostOS::Env

Defined in:
lib/host-os.rb

Overview

Note:

When no environment is configured production is assumed.

This module allows to identify the current environment by checking the ENV for the following variables in order:

  • RAILS_ENV
  • RACK_ENV
  • ENVIRONMENT
  • ENV

You can check for any boolean attribute:

Examples:

Query if the environment is configured as "staging"

HostOS.env.staging?

Test if the environment is configured as "production"

HostOS.env.is? :production

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.development?true, false (readonly)

Returns whether the environment is configured as "development".

Returns:

  • (true, false)

    whether the environment is configured as "development"



# File 'lib/host-os.rb', line 206

.idSymbol (readonly)

Returns environment identifier.

Returns:

  • (Symbol)

    environment identifier



# File 'lib/host-os.rb', line 210

.production?true, false (readonly)

Note:

This will return true if the environment is not configured.

Returns whether the environment is configured as "production".

Returns:

  • (true, false)

    whether the environment is configured as "production"



# File 'lib/host-os.rb', line 199

.test?true, false (readonly)

Returns whether the environment is configured as "test".

Returns:

  • (true, false)

    whether the environment is configured as "test"



# File 'lib/host-os.rb', line 203

Class Method Details

.is?(what) ⇒ true, false

Returns whether the environment is the given identifier.

Parameters:

  • what (Symbol, String)

    the identifier to check

Returns:

  • (true, false)

    whether the environment is the given identifier



# File 'lib/host-os.rb', line 213