Class: ActivePostgres::Rails::DatabaseConfig::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/active_postgres/rails/database_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, app_name: nil, config: nil) ⇒ Builder

Returns a new instance of Builder.



62
63
64
65
66
# File 'lib/active_postgres/rails/database_config.rb', line 62

def initialize(environment, app_name: nil, config: nil)
  @environment = environment
  @app_name = normalize_app_name(app_name)
  @config = config || Configuration.load('config/postgres.yml', environment)
end

Instance Attribute Details

#app_nameObject (readonly)

Returns the value of attribute app_name.



60
61
62
# File 'lib/active_postgres/rails/database_config.rb', line 60

def app_name
  @app_name
end

#configObject (readonly)

Returns the value of attribute config.



60
61
62
# File 'lib/active_postgres/rails/database_config.rb', line 60

def config
  @config
end

#environmentObject (readonly)

Returns the value of attribute environment.



60
61
62
# File 'lib/active_postgres/rails/database_config.rb', line 60

def environment
  @environment
end

Instance Method Details

#build_connectionsObject



68
69
70
71
72
73
74
75
76
77
# File 'lib/active_postgres/rails/database_config.rb', line 68

def build_connections
  connections = {
    'primary' => deep_merge(base_connection, primary_connection_overrides)
  }

  replica_config = replica_connection_overrides
  connections['primary_replica'] = deep_merge(base_connection, replica_config) if replica_config

  connections
end