Module: PgRls::Tenant::Securable

Extended by:
ActiveSupport::Concern
Included in:
PgRls::Tenant
Defined in:
app/models/pg_rls/tenant/securable.rb

Overview

Securable Module

Instance Method Summary collapse

Instance Method Details

#readonly?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'app/models/pg_rls/tenant/securable.rb', line 44

def readonly?
  true
end

#set_rls(connection = PgRls::Record.connection) ⇒ Object



35
36
37
38
39
40
41
42
# File 'app/models/pg_rls/tenant/securable.rb', line 35

def set_rls(connection = PgRls::Record.connection)
  self.class.reset_rls_used_connections if new_tenant?
  return self if reused_connection?(connection)

  connection.exec_query("SET rls.tenant_id = '#{tenant_id}'")

  self
end