Class: Rabbitek::Server::Hooks::ActiveRecordConnectionReset
- Inherits:
-
Rabbitek::ServerHook
- Object
- Rabbitek::ServerHook
- Rabbitek::Server::Hooks::ActiveRecordConnectionReset
- Defined in:
- lib/rabbitek/server/hooks/active_record_connection_reset.rb
Overview
Active record connection reset to maintain correct connection state Used only in Rails < 5
Instance Method Summary collapse
- #call(consumer, message) ⇒ Object
-
#initialize ⇒ ActiveRecordConnectionReset
constructor
A new instance of ActiveRecordConnectionReset.
Constructor Details
#initialize ⇒ ActiveRecordConnectionReset
Returns a new instance of ActiveRecordConnectionReset.
12 13 14 |
# File 'lib/rabbitek/server/hooks/active_record_connection_reset.rb', line 12 def initialize raise ArgumentError, 'Use AR connection reset only in Rails < 5!' unless should_allow_hook? end |
Instance Method Details
#call(consumer, message) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/rabbitek/server/hooks/active_record_connection_reset.rb', line 16 def call(consumer, ) ::ActiveRecord::Base.establish_connection unless ::ActiveRecord::Base.connection.active? super ensure ::ActiveRecord::Base.clear_active_connections! end |