Module: ConfigSL::FromEnvironment

Included in:
Config
Defined in:
lib/configsl/from_environment.rb

Overview

Load configuration from the environment.

This module provides a way to load configuration values from environment variables. It checks for a variables using the name of the option, in upper snake case (e.g. ‘MY_OPTION`). You can add a prefix to all variable names using `from_environment_prefix`.

from_environment_prefix 'DATABASE_'
option :host, default: 'localhost'

You can override the variable name for individual options by setting ‘env_variable`.

option :host, default: 'localhost', env_variable: 'DB_HOST'

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



19
20
21
22
# File 'lib/configsl/from_environment.rb', line 19

def self.included(base)
  base.extend ClassMethods
  base.from_environment_prefix ''
end