Class: WarpCore::Env
- Inherits:
-
Object
- Object
- WarpCore::Env
- Defined in:
- lib/warpcore/config.rb
Overview
Class provides a helper method to load
Class Method Summary collapse
-
.load_url!(url = nil) ⇒ Boolean
Applies a remote JSON hash containing the ENV keys and values from a remote URL.
Class Method Details
.load_url!(url = nil) ⇒ Boolean
Applies a remote JSON hash containing the ENV keys and values from a remote URL. Values from the JSON hash are only applied to the current ENV hash ONLY if it does not already have a value. Therefore local ENV values will take precedence over remote ones. By default, it uses the url in value in ENV.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/warpcore/config.rb', line 14 def self.load_url!(url = nil) url ||= ENV["ENV_URL"] if url.present? begin remote_config = JSON.load open( url ) remote_config.each do |key,value| k = key.upcase ENV[k] ||= value.to_s end return true rescue => e warn "[WarpCore::Config] Error loading config: #{url} (#{e})" end end false end |