action_policy-graphiti 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +12 -1
- data/lib/action_policy/graphiti/behaviour.rb +8 -0
- data/lib/action_policy/graphiti/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14c1d111ab3637ca0a0473052745648b29d59eae102983f2352aee57cad48b91
|
4
|
+
data.tar.gz: ef0f1e0ba47fbf1091c471dae9a0b6902c9c63cd238f5325c5af19afe82936db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94e2a8414ab817b697a36de4c438e29ed5f9b610b30cf2f551b2598e56e257443a6adabecea6af9d43553376279b024cce266d45ec687b7809157eed9ab7d63a
|
7
|
+
data.tar.gz: 014b16778a53046c51d6851d1e8d8298fbec0840d0dbd6de898441d2f2d71e7fd07b19ae09842de7e7fae0a61462c79c3c736e1ae5e146a6ce7299e815b9184e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -64,7 +64,18 @@ class TestResource < ApplicationResource
|
|
64
64
|
# or just plain authorize_scope
|
65
65
|
end
|
66
66
|
```
|
67
|
-
|
67
|
+
|
68
|
+
You can also use a handy shortcut (you can also use an explicit `with` argument just as with other `authorize_` class methods) to authorize `create`, `update`, `destroy` methods and also apply scoping:
|
69
|
+
```ruby
|
70
|
+
class TestResource < ApplicationResource
|
71
|
+
include ActionPolicy::Graphiti::Behaviour
|
72
|
+
|
73
|
+
authorize_and_scope_all with: 'TestExplicitPolicy'
|
74
|
+
# or just plain authorize_and_scope_all if you want to deduce the policy class
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
**Note:** current implementation requires you to place `authorize_scope` (and `authorize_and_scope_all` too) call **after** the explicit `base_scope` method (scoping is performed by base scope results modification).
|
68
79
|
|
69
80
|
You can also use authorization context building inside Graphiti resources (just like with Action Policy in controllers):
|
70
81
|
```ruby
|
@@ -80,6 +80,14 @@ module ActionPolicy
|
|
80
80
|
)
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
def authorize_and_scope_all(**arguments)
|
85
|
+
authorize_scope(**arguments)
|
86
|
+
|
87
|
+
authorize_create(**arguments)
|
88
|
+
authorize_update(**arguments)
|
89
|
+
authorize_destroy(**arguments)
|
90
|
+
end
|
83
91
|
end
|
84
92
|
|
85
93
|
def self.included(base)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_policy-graphiti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Mochalov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: action_policy
|