Module: PgRls::ActiveRecord::ConnectionAdapters::ConnectionPool

Defined in:
lib/pg_rls/active_record/connection_adapters/connection_pool.rb

Overview

ActiveRecord ConnectionPool Connection Adapter Extension

Instance Method Summary collapse

Instance Method Details

#checkout(checkout_timeout = @checkout_timeout) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/pg_rls/active_record/connection_adapters/connection_pool.rb', line 8

def checkout(checkout_timeout = @checkout_timeout)
  conn = super
  return conn unless rls_connection?
  return reset_rls_used_connections(conn) if PgRls::Current.tenant.nil?

  PgRls::Current.tenant.set_rls(conn)
  conn
end

#reset_rls_used_connections(connection) ⇒ Object



21
22
23
# File 'lib/pg_rls/active_record/connection_adapters/connection_pool.rb', line 21

def reset_rls_used_connections(connection)
  PgRls::Tenant.reset_rls_used_connections(connection)
end

#rls_connection?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/pg_rls/active_record/connection_adapters/connection_pool.rb', line 17

def rls_connection?
  pool_config.db_config.configuration_hash[:rls] == true
end