module ConfigEnv
Constants
- VERSION
Public Class Methods
clear()
click to toggle source
# File lib/config_env.rb, line 27 def self.clear vars_hash.clear end
environment()
click to toggle source
# File lib/config_env.rb, line 31 def self.environment ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' end
init(path_to_config)
click to toggle source
# File lib/config_env.rb, line 9 def self.init(path_to_config) @path = path_to_config Kernel.load(path) if File.exists?(path) end
path()
click to toggle source
# File lib/config_env.rb, line 14 def self.path @path end
path_to_config(new_path)
click to toggle source
DEPRECATED. Use ‘init`
# File lib/config_env.rb, line 5 def self.path_to_config(new_path) init(new_path) end
vars(environment = nil)
click to toggle source
# File lib/config_env.rb, line 18 def self.vars(environment = nil) environment = (environment || self.environment).to_s vars = (vars_hash[environment] || {}).clone vars.merge!(vars_hash["any"] || {}) vars end
Private Class Methods
set_envs(vars, envs)
click to toggle source
# File lib/config_env.rb, line 37 def self.set_envs(vars, envs) envs = envs.map(&:to_s) envs.each do |env| vars_hash[env] ||= {} vars_hash[env].merge!(vars) end if envs == ['any'] || envs.include?(environment) vars.each do |key, value| ENV[key] = value end end end
vars_hash()
click to toggle source
# File lib/config_env.rb, line 52 def self.vars_hash @vars ||= {} end