class WarpCore::Env
Class provides a helper method to load
Public Class Methods
load_url!(url = nil)
click to toggle source
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. @param url [String] the remote url that responds with the JSON body. @return [Boolean] true if the JSON hash was found and applied successfully.
# 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