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 190

.idSymbol (readonly)

Returns environment identifier.

Returns:

  • (Symbol)

    environment identifier



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

.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 182

.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 187

Class Method Details

.is?(what) ⇒ true, false

Returns whether the environment is the given identifier.

Parameters:

  • what (#to_sym, #to_s)

    the identifier to check

Returns:

  • (true, false)

    whether the environment is the given identifier



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