Class: Sequelizer::EnvConfig
- Inherits:
-
Object
- Object
- Sequelizer::EnvConfig
- Defined in:
- lib/sequelizer/env_config.rb
Overview
Creates a set of database configuration options from environment variables
Instance Method Summary collapse
-
#options ⇒ Object
Any environment variables in the .env file are loaded and then any environment variable starting with SEQUELIZER_ will be used as an option for the database.
Instance Method Details
#options ⇒ Object
Any environment variables in the .env file are loaded and then any environment variable starting with SEQUELIZER_ will be used as an option for the database
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sequelizer/env_config.rb', line 10 def Dotenv.load seq_config = ENV.keys.select { |key| key =~ /^SEQUELIZER_/ }.inject({}) do |config, key| new_key = key.gsub(/^SEQUELIZER_/, '').downcase config[new_key] = ENV[key] config end db_config = ENV.keys.select { |key| key =~ /_DB_OPT_/ }.inject({}) do |config, key| new_key = key.downcase config[new_key] = ENV[key] config end db_config.merge(seq_config) end |