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

Instance Method Details

#configs_for(include_hidden: false, name: nil) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/switchman/active_record/database_configurations.rb', line 11

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