Module: PgRls::ActiveRecord::ConnectionAdapters::PostgreSQL::RlsFunctions
- Includes:
- SqlHelperMethod
- Defined in:
- lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_functions.rb
Overview
This module contains the logic to create, drop and validate RLS functions
Instance Method Summary collapse
- #create_rls_functions ⇒ Object
- #drop_rls_functions ⇒ Object
- #function_exists?(function_name) ⇒ Boolean
Instance Method Details
#create_rls_functions ⇒ Object
21 22 23 24 25 |
# File 'lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_functions.rb', line 21 def create_rls_functions create_rls_exception create_tenant_id_setter_function create_tenant_id_update_blocker_function end |
#drop_rls_functions ⇒ Object
27 28 29 30 31 |
# File 'lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_functions.rb', line 27 def drop_rls_functions drop_function("tenant_id_setter") drop_function("rls_exception") drop_function("tenant_id_update_blocker") end |
#function_exists?(function_name) ⇒ Boolean
11 12 13 14 15 16 17 18 19 |
# File 'lib/pg_rls/active_record/connection_adapters/postgre_sql/rls_functions.rb', line 11 def function_exists?(function_name) query = <<~SQL SELECT 1 FROM pg_proc WHERE proname = '#{function_name}' SQL execute_sql!(query).any? end |