Skip to content

Commit

Permalink
Add code
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-snag2 committed Apr 29, 2024
1 parent ca9548d commit 4918209
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/arproxy/chain_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def initialize(proxy_chain)
end

def execute(sql, name=nil, **kwargs)
self.proxy_chain.connection.execute_without_arproxy sql, name, **kwargs
self.proxy_chain.connection.send(:execute_without_arproxy, sql, name, **kwargs)
end
end
end
15 changes: 12 additions & 3 deletions lib/arproxy/proxy_chain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,24 @@ def execute_with_arproxy(sql, name=nil, **kwargs)
::Arproxy.proxy_chain.connection = self
::Arproxy.proxy_chain.head.execute sql, name, **kwargs
end
alias_method :execute_without_arproxy, :execute
alias_method :execute, :execute_with_arproxy
if private_method_defined?(:raw_execute)
alias_method :execute_without_arproxy, :raw_execute
alias_method :raw_execute, :execute_with_arproxy
else
alias_method :execute_without_arproxy, :execute
alias_method :execute, :execute_with_arproxy
end
::Arproxy.logger.debug("Arproxy: Enabled")
end
end

def disable!
@config.adapter_class.class_eval do
alias_method :execute, :execute_without_arproxy
if private_method_defined?(:raw_execute)
alias_method :raw_execute, :execute_without_arproxy
else
alias_method :execute, :execute_without_arproxy
end
::Arproxy.logger.debug("Arproxy: Disabled")
end
end
Expand Down

0 comments on commit 4918209

Please sign in to comment.