Resolve Tubesock deprecation warnings

This commit is contained in:
Sebastian Serth
2024-02-14 16:01:44 +01:00
committed by Dominic Sauer
parent 95972979e3
commit 790186a1a1

View File

@ -28,3 +28,25 @@ module Sorcery
end end
end end
end end
# Tubesock uses a deprecated method to clear active connections with ActiveRecord.
# Hence, we update the method call to the new method name (including `connection_handler`).
module Tubesock::Hijack
extend ActiveSupport::Concern
# First, we need to remove the old `included` definition.
# Otherwise, we would get an `ActiveSupport::Concern::MultipleIncludedBlocks` exception.
remove_instance_variable :@_included_block
included do
def hijack
sock = Tubesock.hijack(request.env)
yield sock
sock.onclose do
ActiveRecord::Base.connection_handler.clear_active_connections! if defined? ActiveRecord
end
sock.listen
render plain: nil, status: -1
end
end
end