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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b5fda608ae008fec873744642e5ccadf99e72077910cfb3fb848ed05eceb425
4
- data.tar.gz: f77d094525fe60663701cb6df57b8e7a74a64ad0e2316bc18cc7a5fba511bb6d
3
+ metadata.gz: 14c1d111ab3637ca0a0473052745648b29d59eae102983f2352aee57cad48b91
4
+ data.tar.gz: ef0f1e0ba47fbf1091c471dae9a0b6902c9c63cd238f5325c5af19afe82936db
5
5
  SHA512:
6
- metadata.gz: 15d75dac6c2dc71a20e70783668395fc99480c32b5c95c65fbe29637fdb3a36d71dc62ef2f18e675854dfa70ecb02f56bd5d0e327f4f3f34fa413683351f6bbc
7
- data.tar.gz: 0234f15a2aea33a1464a1d5dd5b9b9ec330775ff63af4357dc62408b0ab3d8ecc73d0768946799afc94c4570e9e518e6f33fe71a60ac8c0b90c6ddb260963f5d
6
+ metadata.gz: 94e2a8414ab817b697a36de4c438e29ed5f9b610b30cf2f551b2598e56e257443a6adabecea6af9d43553376279b024cce266d45ec687b7809157eed9ab7d63a
7
+ data.tar.gz: 014b16778a53046c51d6851d1e8d8298fbec0840d0dbd6de898441d2f2d71e7fd07b19ae09842de7e7fae0a61462c79c3c736e1ae5e146a6ce7299e815b9184e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## [0.2.0] - 2023-06-28
4
+
5
+ - Enable authorization shortcuts
6
+
3
7
  ## [0.1.0] - 2023-06-23
4
8
 
5
9
  - Enable explicit policies and actions
data/README.md CHANGED
@@ -64,7 +64,18 @@ class TestResource < ApplicationResource
64
64
  # or just plain authorize_scope
65
65
  end
66
66
  ```
67
- **Note:** current implementation requires you to place `authorize_scope` call **after** the explicit `base_scope` method (scoping is performed by base scope results modification).
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)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActionPolicy
4
4
  module Graphiti
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
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.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-23 00:00:00.000000000 Z
11
+ date: 2023-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: action_policy