action_policy-graphiti 0.1.0 → 0.2.1
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/CHANGELOG.md +4 -0
- data/README.md +12 -1
- data/lib/action_policy/graphiti/behaviour.rb +8 -0
- data/lib/action_policy/graphiti/resource_analyzer.rb +1 -1
- 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: e9ef7ebb5a2a2586e809f9580e6d7eb7f01dc61db0d9f142743e047c3e749efc
|
4
|
+
data.tar.gz: 6531c722163597d7257f16aea9b67be101bd2d27de478b33eafd069798ad1db6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65f8fde558045c31d5f414e621c1e87d1cb109c8518a64b223211a8b941c9814a2b2c01190bc18264fced4ff3663f47d56cc4d6dfdd0af5d763ac33f37b50f6b
|
7
|
+
data.tar.gz: 165cbd931cea33c75c3b1400995c8d5e4763dcd710eb671dbce1d235ae51ed24c98e633231bcacd4af4c391fda7a66d0b658590e37340cc1eb9a9bb139017dcf
|
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)
|
@@ -15,7 +15,7 @@ module ActionPolicy
|
|
15
15
|
def self.base_resource_class(polymorphic_resource)
|
16
16
|
return unless ResourceValidator.polymorphic_graphiti_resource?(polymorphic_resource)
|
17
17
|
|
18
|
-
resource_class =
|
18
|
+
resource_class = polymorphic_resource.is_a?(Class) ? polymorphic_resource : polymorphic_resource.class
|
19
19
|
|
20
20
|
polymorphic_marker_index = resource_class.ancestors.find_index(::Graphiti::Resource::Polymorphism)
|
21
21
|
|
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.1
|
4
|
+
version: 0.2.1
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: action_policy
|