Class: Sequelizer::EnvConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/sequelizer/env_config.rb

Overview

Creates a set of database configuration options from environment variables

Instance Method Summary collapse

Instance Method Details

#optionsObject

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
# File 'lib/sequelizer/env_config.rb', line 10

def options
  Dotenv.load
  env_config = ENV.keys.select { |key| key =~ /^SEQUELIZER_/ }.inject({}) do |config, key|
    new_key = key.gsub(/^SEQUELIZER_/, '').downcase
    config[new_key] = ENV[key]
    config
  end
  env_config.empty? ? nil : env_config
end