diff --git a/lib/active_record/connection_adapters/percona_adapter.rb b/lib/active_record/connection_adapters/percona_adapter.rb index d2029edd..ef59e76b 100644 --- a/lib/active_record/connection_adapters/percona_adapter.rb +++ b/lib/active_record/connection_adapters/percona_adapter.rb @@ -13,7 +13,12 @@ def percona_connection(config) config = config.dup if config.frozen? config[:username] = 'root' end - connection = send("#{Departure.configuration.adapter}_connection", config) + adapter = config[:adapter] + connection = if Departure::SUPPORTED_ADAPTERS.include?(adapter) + send("#{adapter}_connection", config) + else + raise ArgumentError, "Supported Departure adapters are #{Departure::SUPPORTED_ADAPTERS.inspect}" + end connection_details = Departure::ConnectionDetails.new(config) verbose = ActiveRecord::Migration.verbose diff --git a/lib/departure.rb b/lib/departure.rb index be85c674..f2e38bf1 100644 --- a/lib/departure.rb +++ b/lib/departure.rb @@ -28,6 +28,8 @@ end module Departure + SUPPORTED_ADAPTERS = %i[trilogy mysql2].freeze + class << self attr_accessor :configuration end diff --git a/lib/departure/configuration.rb b/lib/departure/configuration.rb index e43396a6..a7dfcf5f 100644 --- a/lib/departure/configuration.rb +++ b/lib/departure/configuration.rb @@ -1,9 +1,6 @@ module Departure class Configuration - SUPPORTED_ADAPTERS = %i[trilogy mysql2].freeze - attr_accessor :tmp_path, :global_percona_args, :enabled_by_default, :redirect_stderr - attr_reader :adapter def initialize @tmp_path = '.'.freeze @@ -18,14 +15,6 @@ def error_log_path File.join(tmp_path, error_log_filename) end - def adapter=(name) - unless SUPPORTED_ADAPTERS.include?(name) - raise ArgumentError, "Supported Departure adapters are #{SUPPORTED_ADAPTERS.inspect}" - end - - @adapter = name - end - private attr_reader :error_log_filename