Module: Switchman::ActiveRecord::DatabaseConfigurations
- Defined in:
- lib/switchman/active_record/database_configurations.rb,
lib/switchman/active_record/database_configurations/database_config.rb
Defined Under Namespace
Modules: DatabaseConfig
Instance Method Summary collapse
-
#configs_for(include_replicas: false, name: nil) ⇒ Object
key difference: For each env name, ensure only one writable config is returned since all should point to the same data, even if multiple are writable (Picks ‘primary’ since it is guaranteed to exist and switchman handles activating deploy through other means).
Instance Method Details
#configs_for(include_replicas: false, name: nil) ⇒ Object
key difference: For each env name, ensure only one writable config is returned since all should point to the same data, even if multiple are writable (Picks ‘primary’ since it is guaranteed to exist and switchman handles activating deploy through other means)
10 11 12 13 14 15 16 17 18 |
# File 'lib/switchman/active_record/database_configurations.rb', line 10 def configs_for(include_replicas: false, name: nil, **) res = super if name && !include_replicas return nil unless name.end_with?('primary') elsif !include_replicas return res.select { |config| config.name.end_with?('primary') } end res end |