Module: DbCharmerEnvUrls
- Defined in:
- lib/db_charmer_env_urls.rb,
lib/db_charmer_env_urls/engine.rb,
lib/db_charmer_env_urls/version.rb
Defined Under Namespace
Classes: Engine
Constant Summary collapse
- VERSION =
"1.1.2"
Class Method Summary collapse
-
.database_configurations ⇒ Hash
Extracts database configs from the ENV where ENV key ends it _DATABASE_URL.
Class Method Details
.database_configurations ⇒ Hash
Extracts database configs from the ENV where ENV key ends it _DATABASE_URL
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/db_charmer_env_urls.rb', line 23 def self.database_configurations base = ActiveRecord::Base ENV.inject({}) do |acc, (key, url)| if matches = key.match(/\A(\w+)_DATABASE_URL\z/) config = base::ConnectionSpecification::Resolver.new(url, base.configurations).spec.config acc[matches[1].downcase] = config.stringify_keys end acc end end |