diff --git a/.rubocop.yml b/.rubocop.yml index ed58f2f..f3a694e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,4 +9,7 @@ Rails/Delegate: Metrics/BlockLength: Exclude: - - spec/**/* \ No newline at end of file + - spec/**/* + +Metrics/AbcSize: + Max: 22 diff --git a/lib/active_record/connection_adapters/janus_mysql2_adapter.rb b/lib/active_record/connection_adapters/janus_mysql2_adapter.rb index 1225af6..527927b 100644 --- a/lib/active_record/connection_adapters/janus_mysql2_adapter.rb +++ b/lib/active_record/connection_adapters/janus_mysql2_adapter.rb @@ -25,7 +25,11 @@ class JanusMysql2Adapter < ActiveRecord::ConnectionAdapters::Mysql2Adapter SQL_SKIP_ALL_MATCHERS = [/\A\s*set\s+local\s/i].freeze def initialize(*args) - args = parse_config(args) + args[0][:janus]['replica']['database'] = args[0][:database] + args[0][:janus]['primary']['database'] = args[0][:database] + + @replica_config = args[0][:janus]['replica'] + args[0] = args[0][:janus]['primary'] super(*args) @connection_parameters ||= args[0] update_config @@ -79,15 +83,6 @@ def clear_cache!(...) private - def parse_config(args) - args[0][:janus]['replica']['database'] = args[0][:database] - args[0][:janus]['primary']['database'] = args[0][:database] - - @replica_config = args[0][:janus]['replica'] - args[0] = args[0][:janus]['primary'] - args - end - def should_send_to_all?(sql) SQL_ALL_MATCHERS.any? { |matcher| sql =~ matcher } && SQL_SKIP_ALL_MATCHERS.none? { |matcher| sql =~ matcher } end diff --git a/lib/janus/version.rb b/lib/janus/version.rb index 1ceddec..1e21e0f 100644 --- a/lib/janus/version.rb +++ b/lib/janus/version.rb @@ -4,7 +4,7 @@ module Janus unless defined?(::Janus::VERSION) module VERSION MAJOR = 0 - MINOR = 4 + MINOR = 5 PATCH = 0 PRE = nil