Module: Anycable::Rails::ActiveRecord::ReleaseConnection

Defined in:
lib/anycable/rails/activerecord/release_connection.rb

Overview

Release ActiveRecord connection after every call (if any)

Instance Method Summary collapse

Instance Method Details

#commandObject



15
16
17
# File 'lib/anycable/rails/activerecord/release_connection.rb', line 15

def command(*)
  wrap_release_connection { super }
end

#connectObject



7
8
9
# File 'lib/anycable/rails/activerecord/release_connection.rb', line 7

def connect(*)
  wrap_release_connection { super }
end

#disconnectObject



11
12
13
# File 'lib/anycable/rails/activerecord/release_connection.rb', line 11

def disconnect(*)
  wrap_release_connection { super }
end

#wrap_release_connectionObject



19
20
21
22
23
24
# File 'lib/anycable/rails/activerecord/release_connection.rb', line 19

def wrap_release_connection
  res = yield
  ::ActiveRecord::Base.connection_pool.release_connection if
    ::ActiveRecord::Base.connection_pool.active_connection?
  res
end