pundit-resources 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pundit/resource.rb +6 -2
- data/lib/pundit/resources/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6137d7adc753176bdf0b684e5030f9dd9863b1f8
|
4
|
+
data.tar.gz: edc5c2f2165be0020e305648decbcbeb80a72c12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45e3b829bcf02ea33640597469b9a4e440505ec6419f705d430f2523fbeff622dfaaca11205611a743358daf08f84306005f7670a29f62158dc267353189e9fa
|
7
|
+
data.tar.gz: 3ec8f3504f1debe139b6ebfd3f5594af521c2d0ef0cdb0432ffd0cc1f48c74ba69deef79fc4da3d934ab735fd717464023e66cccfaa091fc786aa1fe91921413
|
data/lib/pundit/resource.rb
CHANGED
@@ -5,6 +5,8 @@ module Pundit
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
+
define_jsonapi_resources_callbacks :policy_authorize
|
9
|
+
|
8
10
|
before_save :authorize_create_or_update
|
9
11
|
before_remove :authorize_destroy
|
10
12
|
end
|
@@ -32,8 +34,10 @@ module Pundit
|
|
32
34
|
protected
|
33
35
|
|
34
36
|
def can(method)
|
35
|
-
|
36
|
-
|
37
|
+
run_callbacks :policy_authorize do
|
38
|
+
context[:policy_used]&.call
|
39
|
+
policy.public_send(method)
|
40
|
+
end
|
37
41
|
end
|
38
42
|
|
39
43
|
def current_user
|