Last active
May 24, 2021 04:39
-
-
Save jpawlyn/dbb2b3c27adf2c5b31edda0c00133ced to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyGem | |
class DbConfig | |
CONFIGURATIONS = Psych.safe_load( | |
ERB.new( | |
File.read(File.join(File.dirname(__FILE__), '../../config/databases.yml')) | |
).result, | |
aliases: true | |
) | |
DB_ENV = (Rails.env if defined?(Rails)) || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development' | |
class << self | |
def configurations | |
CONFIGURATIONS[DB_ENV.to_s] | |
end | |
def db_key | |
RequestStore.store[:mygem_database_key] | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment