Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure ArResolver works for other adapter with proxy #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to be able to specify an extend module(like OtherAdapterProxy) in a configurations.

example:
config/initializers/fresh_connection.rb

FreshConnection.extend_adapter_proxy = OtherAdapterProxy

Could you to be able to add a function like above?
If it seems difficult for you, I will implement it.

)
end

specification
Expand Down