Module: Cloudinary::Config

Includes:
BaseConfig
Defined in:
lib/cloudinary/config.rb

Constant Summary collapse

ENV_URL =
"CLOUDINARY_URL"
SCHEME =
"cloudinary"

Instance Method Summary collapse

Methods included from BaseConfig

#load_from_url, #update

Instance Method Details

#load_config_from_envObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cloudinary/config.rb', line 8

def load_config_from_env
  if ENV["CLOUDINARY_CLOUD_NAME"]
    config_keys = ENV.keys.select! { |key| key.start_with? "CLOUDINARY_" }
    config_keys -= ["CLOUDINARY_URL"] # ignore it when explicit options are passed
    config_keys.each do |full_key|
      conf_key = full_key["CLOUDINARY_".length..-1].downcase # convert "CLOUDINARY_CONFIG_NAME" to "config_name"
      conf_val = ENV[full_key]
      conf_val = conf_val == 'true' if %w[true false].include?(conf_val) # cast relevant boolean values
      update(conf_key => conf_val)
    end
  elsif ENV[ENV_URL]
    load_from_url(ENV[ENV_URL])
  end
end