Skip to content

Commit

Permalink
Make sure ArResolver works for other adapter with proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
untwal committed Feb 24, 2021
1 parent cb446dc commit 66bc23f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/fresh_connection/extend/adapters/other_adapter_proxy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module FreshConnection
module Extend
module OtherAdapterProxy
private

def __change_connection
yield
end
end
end
end
7 changes: 6 additions & 1 deletion lib/fresh_connection/extend/ar_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ def spec(*args)
require 'fresh_connection/extend/adapters/pg_adapter'
__extend_adapter_by_fc(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter, PgAdapter)
else
raise NotImplementedError, "This adapter('#{specification.config[:adapter]}') is not supported. If you specified the mysql or postgres adapter, it's probably a bug in FreshConnection. Please teach me (https://github.com/tsukasaoishi/fresh_connection/issues/new)"
require 'fresh_connection/extend/adapters/other_adapter_proxy'
base_adapter_name = "#{specification.config[:adapter].to_s}_adapter".camelize
__extend_adapter_by_fc(
"::ActiveRecord::ConnectionAdapters::#{base_adapter_name}".constantize,
OtherAdapterProxy
)
end

specification
Expand Down

0 comments on commit 66bc23f

Please sign in to comment.