panda_pal 5.16.5 → 5.16.6
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 +4 -4
- data/config/initializers/apartment.rb +31 -1
- data/lib/panda_pal/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb2e310fa2edf0bc70f0a4f4e91bc2358b3489cb472571e8f3cc18ee387a04fb
|
4
|
+
data.tar.gz: 6baaf5e388cea773faee2f8d65defa4ea64b9feb28412e5f900fc9bbb62d5e34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b19c8454c7333ee1397c78f068db3d1557d422ac8487167d24458ad4e4e6f1857e2c1e16e7ee1793bf50a20fc0a88836e4a4a30cc74a0f6556d970172accde1f
|
7
|
+
data.tar.gz: 63fbc3723c539588adf9c312da99a55cd559874913ed2a4e0ea6f13f1ad0850f4d580e199055ffaf2f0b5eb99b00a55df83294272557e2b1129e07d5eedcd25f
|
@@ -259,6 +259,36 @@ ActiveSupport.on_load(:action_cable) do
|
|
259
259
|
def tenant
|
260
260
|
@tenant || 'public'
|
261
261
|
end
|
262
|
+
|
263
|
+
def panda_session
|
264
|
+
unless defined?(@panda_session)
|
265
|
+
@panda_session = PandaPal::Session.for_request(request, enforce_tenant: :switch)
|
266
|
+
@tenant ||= Apartment::Tenant.current
|
267
|
+
end
|
268
|
+
@panda_session
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
ActionCable::Channel::Base.module_eval do
|
273
|
+
delegate :panda_session, to: :connection
|
274
|
+
|
275
|
+
if defined?(CanCan)
|
276
|
+
set_callback(:subscribe, :around) do |_, blk|
|
277
|
+
blk.call
|
278
|
+
rescue CanCan::AccessDenied
|
279
|
+
reject
|
280
|
+
end
|
281
|
+
|
282
|
+
delegate :current_ability, to: :connection
|
283
|
+
|
284
|
+
def authorize!(*args, **kwargs)
|
285
|
+
current_ability.authorize!(*args, **kwargs)
|
286
|
+
end
|
287
|
+
|
288
|
+
def authorized?(*args, **kwargs)
|
289
|
+
current_ability.can?(*args, **kwargs)
|
290
|
+
end
|
291
|
+
end
|
262
292
|
end
|
263
293
|
|
264
294
|
# Include the Current Tenant in any broadcastings
|
@@ -281,7 +311,7 @@ ActiveSupport.on_load(:action_cable) do
|
|
281
311
|
end
|
282
312
|
|
283
313
|
# Lazily switch any worker threads to the correct tenant when they are working
|
284
|
-
# Actively calling `switch_tenant`
|
314
|
+
# Actively calling `switch_tenant` checks out a DB connection and calls `SET search_path`.
|
285
315
|
# The message processing may not interface with the DB, so this would be a huge waste.
|
286
316
|
# Instead, we ensure that the thread will trigger a :checkout if it needs a connection,
|
287
317
|
# at which time we hack-in the correct tenant/schema.
|
data/lib/panda_pal/version.rb
CHANGED