module Early
Early
checks for environment variables availability, so you don't have to.
Hook it early in your program and work with `ENV` like you normally would. This time, however, the errors would be thrown early and not when a critical piece of code is hit, which may happen late in the program runtime an be easy to miss.
Constants
- VERSION
Public Class Methods
apply(config)
click to toggle source
Applies a configuration, which means every variable is either defaulted or checked for existence.
# File lib/early.rb, line 85 def self.apply(config) config.variables.each(&:apply) end
const_missing(name)
click to toggle source
Accessing environment variables as constants. Raises Early::Error
if missing.
# File lib/early.rb, line 91 def self.const_missing(name) RequiredVariable.new(name).apply end
env()
click to toggle source
Env returns the early environment. This is either the value of RAILS_ENV, RACK_ENV (in that order) or the string 'development'
if neither of the aforementioned environment variables are present.
# File lib/early.rb, line 79 def self.env ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' end