pg_rls 0.0.2.6.8 → 0.0.2.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc943514fa325ad95f2d7d85d7fe5a4762ecafaf9b57d9771bca3ddffc3d2367
4
- data.tar.gz: 1cc1557cdde8daeb4e35d08ef9f0a824284618c9a654229a41656aec4a3d218b
3
+ metadata.gz: c7c7b686aae14aefce3ba60e75a32c32a57d5bfa5cf561bad8dec24f0677eadd
4
+ data.tar.gz: 6e3aee5e06df6b3be7fdafc5a8da650390521f83b313c0df4a5bfe2d9e9cf051
5
5
  SHA512:
6
- metadata.gz: cd54605be45451657431ddb5659d38d083b10a631b6424712623924bf96629cfa0393a3f0dd7a20e4142c37ae4b30ef72daeaf696e1d836ce6a16b2a9691cf83
7
- data.tar.gz: 3420d2fe1f6375e6607267f6db6857c0bb9348cfde42ccea9ce9cf40c8e23f02443b45fe59a39a52db2a48f0d94a3b143a95a6229a41f2a160b0eb3aa204bc55
6
+ metadata.gz: 2db3d52130f8cc848ca6a748157aaab6f74228c03f0304fb4a2d2b91005ec651bf01e20b9c31ea115da0a204978bc6aadee53742dca86f686ede7a40b1ade0dd
7
+ data.tar.gz: a55073c1d2ea30000f53668897f8625dba41a564aec9e5cb20782e27722dd594876db5b0fa0f71f73e70c0ac139005bc4d3afb62477550226d78e11d8c299a4f
@@ -13,7 +13,9 @@ module PgRls
13
13
 
14
14
  return @app.call(env) if tenant.blank?
15
15
 
16
- PgRls::Tenant.with_tenant(tenant) { @app.call(env) }
16
+ PgRls::Tenant.with_tenant!(tenant) { @app.call(env) }
17
+ rescue PgRls::Errors::TenantNotFound
18
+ @app.call(env)
17
19
  rescue ActiveRecord::RecordNotFound => e
18
20
  raise e unless rails_active_storage_request?(env)
19
21
 
@@ -7,8 +7,7 @@ module PgRls
7
7
  # Set PgRls Policies
8
8
  class Server
9
9
  def call(_job_instance, msg, _queue)
10
- PgRls::Tenant.with_tenant(msg['pg_rls']) do
11
- process_class = msg['args'].first['job_class']
10
+ PgRls::Tenant.with_tenant!(msg['pg_rls']) do
12
11
  yield
13
12
  end
14
13
  end
@@ -18,9 +18,9 @@ module PgRls
18
18
 
19
19
  def switch_tenant!(&block)
20
20
  fetched_tenant = session[:_tenant] || current_tenant
21
- return if PgRls::Tenant.fetch.present?
21
+ return block.call if PgRls::Tenant.fetch.present?
22
22
 
23
- Tenant.with_tenant(fetched_tenant) do |tenant|
23
+ Tenant.with_tenant!(fetched_tenant) do |tenant|
24
24
  session[:_tenant] = tenant
25
25
  block.call(tenant)
26
26
  end
data/lib/pg_rls/tenant.rb CHANGED
@@ -27,11 +27,11 @@ module PgRls
27
27
 
28
28
  def find_each(&)
29
29
  PgRls.main_model.find_each do |tenant|
30
- with_tenant(tenant, &)
30
+ with_tenant!(tenant, &)
31
31
  end
32
32
  end
33
33
 
34
- def with_tenant(resource, &block)
34
+ def with_tenant!(resource, &block)
35
35
  tenant = switch_tenant!(resource)
36
36
 
37
37
  block.call(tenant) if block_given?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRls
4
- VERSION = '0.0.2.6.8'
4
+ VERSION = '0.0.2.6.10'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_rls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.6.8
4
+ version: 0.0.2.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Laloush