Class: RbacRls::Permission

Inherits:
ApplicationRecord show all
Defined in:
app/models/rbac_rls/permission.rb

Class Method Summary collapse

Class Method Details

.all_tables(schema = :public) ⇒ Object



15
16
17
18
19
20
21
# File 'app/models/rbac_rls/permission.rb', line 15

def self.all_tables(schema = :public)

  sql = "SELECT table_name FROM information_schema.tables #{where_schema(schema)} "
  result = ActiveRecord::Base.connection.select_all(sql)
  tables = result.map { |k| k['table_name'] }
  tables
end

.where_schema(schema_name = nil) ⇒ Object



23
24
25
# File 'app/models/rbac_rls/permission.rb', line 23

def self.where_schema(schema_name = nil)
  schema_name.present? ? "WHERE table_schema  = '#{schema_name}'" : ''
end