Skip to content

Commit

Permalink
rename var for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
David Kutalek authored and David Kutalek committed Aug 14, 2024
1 parent a8da25d commit 135c4c8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/knockoff/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class Config
attr_reader :replica_configs

# A hash of replica configs to their config hash.
attr_reader :replicas_configurations
attr_reader :replicas_configuration_hash

def initialize
@environment = 'development'
@replicas_configurations = {}
@replicas_configuration_hash = {}
set_replica_configs

if !properly_configured? && Knockoff.enabled
Expand Down Expand Up @@ -58,7 +58,7 @@ def update_replica_configs(new_configs)
updated_config = new_configs.deep_dup.merge!(ActiveRecord::Base.configurations.configs_for(env_name: 'knockoff_replicas').first.configuration_hash)
end

@replicas_configurations.each do |key, _config|
@replicas_configuration_hash.each do |key, _config|
update_replica_config(key, updated_config)
end
end
Expand All @@ -73,16 +73,16 @@ def properly_configured?
private

def update_replica_config(key, updated_config)
merged_config = @replicas_configurations[key].configuration_hash.deep_dup.merge!(updated_config)
@replicas_configurations[key] = ActiveRecord::DatabaseConfigurations::HashConfig.new(key, key, merged_config)
ActiveRecord::Base.configurations.configurations << @replicas_configurations[key]
merged_config = @replicas_configuration_hash[key].configuration_hash.deep_dup.merge!(updated_config)
@replicas_configuration_hash[key] = ActiveRecord::DatabaseConfigurations::HashConfig.new(key, key, merged_config)
ActiveRecord::Base.configurations.configurations << @replicas_configuration_hash[key]
end

def register_replica_copy(index, env_key, configuration_hash)
key = "knockoff_replica_#{index}"
new_config = create_replica_copy(env_key, key, configuration_hash.deep_dup)
ActiveRecord::Base.configurations.configurations << new_config
@replicas_configurations[key] = new_config
@replicas_configuration_hash[key] = new_config
end

def create_replica_copy(env_key, key, replica_config_hash)
Expand Down

0 comments on commit 135c4c8

Please sign in to comment.