lib/rls_rails/dsl/policy_factory.rb
def using_table(other_tbl, match: nil, primary_key: match, foreign_key: match, tenant_id: tenant_fk, &block)
      other_tbl = derive_rel_tbl other_tbl
      p = policy("match_#{other_tbl}_on_#{primary_key}_eq_#{foreign_key}".to_sym) do
        using <<-SQL
    EXISTS (
      SELECT NULL
      FROM #{other_tbl}
      WHERE #{@tbl}.#{primary_key} = #{other_tbl}.#{foreign_key}
        AND #{other_tbl}.#{tenant_id} = current_tenant_id()
    )
        SQL
      end
      p.instance_eval(&block) if block_given?
      p
    end
# Shorthand to create a policy that admits rows that find a join partner in another table
Shorthand to create a policy that admits rows that find a join partner in another table
Shorthand to create a policy that admits rows that find a join partner in another table
def using_table(other_tbl, match: nil, primary_key: match, foreign_key: match, tenant_id: tenant_fk, &block)
      other_tbl = derive_rel_tbl other_tbl
      p = policy("match_#{other_tbl}_on_#{primary_key}_eq_#{foreign_key}".to_sym) do
        using <<-SQL
    EXISTS (
      SELECT NULL
      FROM #{other_tbl}
      WHERE #{@tbl}.#{primary_key} = #{other_tbl}.#{foreign_key}
        AND #{other_tbl}.#{tenant_id} = current_tenant_id()
    )
        SQL
      end
      p.instance_eval(&block) if block_given?
      p
    end
def using_table ( other_tbl , match : nil , primary_key : match , foreign_key : match , tenant_id : tenant_fk , & block ) other_tbl = derive_rel_tbl other_tbl p = policy ( "match_#{other_tbl}_on_#{primary_key}_eq_#{foreign_key}" . to_sym ) do using <<-SQL 
    EXISTS (
      SELECT NULL
      FROM  #{ other_tbl } 
      WHERE  #{ @tbl } . #{ primary_key }  =  #{ other_tbl } . #{ foreign_key } 
        AND  #{ other_tbl } . #{ tenant_id }  = current_tenant_id()
    )
         SQL end p . instance_eval ( & block ) if block_given? p end
Shorthand to create a policy that admits rows that find a join partner in another table
Shorthand to create a policy that admits rows that find a join partner in another table
other_tbl
match
primary_key
foreign_key
tenant_id
tenant_fk
block