Link Search Menu Expand Document

Usage

Trifle::Env comes with []= and [] module methods.

Get

Classic of all, all you need is to use brackets and provide key for env variable youre trying to get. Can be lowcaps, upcase, symbol or string.

Trifle::Env['AUTH_TOKEN']
Trifle::Env['auth_token']
Trifle::Env[:auth_token]

Set

Until you set variable, get will always return nil.

Trifle::Env['AUTH_TOKEN']
=> nil
Trifle::Env['AUTH_TOKEN'] = 'supersecrettoken'
=> true
Trifle::Env['AUTH_TOKEN']
=> 'supersecrettoken'

When to use ENV and when Trifle::Env

The rule of thumb is that as long as you don’t need the variable during app initialization, it belongs to DB.