Module: RrxConfig::DatabaseConfig

Defined in:
lib/rrx_config/database_config.rb,
lib/rrx_config/database_config/iam_hash_config.rb

Defined Under Namespace

Classes: IamHashConfig

Class Method Summary collapse

Class Method Details

.db_config_handler(env_name, name, url, config) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rrx_config/database_config.rb', line 8

def db_config_handler(env_name, name, url, config)
  case
  when url
    # Pass to default handler
    nil
  when RrxConfig.database?
    # Use config from RrxConfig
    if RrxConfig.database.try(:iam)
      config = RrxConfig.database.to_h
      RrxConfig.info "Using AWS IAM config for #{obfuscate(config)}"
      IamHashConfig.new(env_name, name, config)
    else
      ActiveRecord::DatabaseConfigurations::HashConfig.new(env_name, name, RrxConfig.database.to_h)
    end
  when config.fetch(:iam, false)
    # Use standard config with IAM support
    IamHashConfig.new(env_name, name, config)
  end
end