1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove UrlConfig#url_config?

This private method is only used in one place, to check whether an
object we have is an instance of `UrlConfig`.

Instead we can just check that we have the right type of object
This commit is contained in:
John Crepezzi 2019-09-18 16:28:20 -04:00
parent 2c14a0f16d
commit c582253e03
3 changed files with 5 additions and 13 deletions

View file

@ -157,7 +157,7 @@ module ActiveRecord
url = config
uri = URI.parse(url)
if uri.scheme
ActiveRecord::DatabaseConfigurations::UrlConfig.new(env_name, spec_name, url)
UrlConfig.new(env_name, spec_name, url)
else
raise InvalidConfigurationError, "'{ #{env_name} => #{config} }' is not a valid configuration. Expected '#{config}' to be a URL string or a Hash."
end
@ -169,15 +169,15 @@ module ActiveRecord
config_without_url = config.dup
config_without_url.delete :url
ActiveRecord::DatabaseConfigurations::UrlConfig.new(env_name, spec_name, url, config_without_url)
UrlConfig.new(env_name, spec_name, url, config_without_url)
else
ActiveRecord::DatabaseConfigurations::HashConfig.new(env_name, spec_name, config)
HashConfig.new(env_name, spec_name, config)
end
end
def merge_db_environment_variables(current_env, configs)
configs.map do |config|
next config if config.url_config? || config.env_name != current_env
next config if config.is_a?(UrlConfig) || config.env_name != current_env
url_config = environment_url_config(current_env, config.spec_name, config.configuration_hash)
url_config || config
@ -188,7 +188,7 @@ module ActiveRecord
url = environment_value_for(spec_name)
return unless url
ActiveRecord::DatabaseConfigurations::UrlConfig.new(env, spec_name, url, config)
UrlConfig.new(env, spec_name, url, config)
end
def environment_value_for(spec_name)

View file

@ -34,10 +34,6 @@ module ActiveRecord
raise NotImplementedError
end
def url_config?
false
end
def for_current_env?
env_name == ActiveRecord::ConnectionHandling::DEFAULT_ENV.call
end

View file

@ -41,10 +41,6 @@ module ActiveRecord
@config
end
def url_config? # :nodoc:
true
end
# Determines whether a database configuration is for a replica / readonly
# connection. If the +replica+ key is present in the config, +replica?+ will
# return +true+.