action_policy 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +233 -171
  3. data/LICENSE.txt +1 -1
  4. data/README.md +7 -11
  5. data/lib/action_policy.rb +7 -1
  6. data/lib/action_policy/behaviour.rb +22 -16
  7. data/lib/action_policy/behaviours/policy_for.rb +10 -3
  8. data/lib/action_policy/behaviours/scoping.rb +2 -1
  9. data/lib/action_policy/behaviours/thread_memoized.rb +1 -3
  10. data/lib/action_policy/ext/module_namespace.rb +1 -6
  11. data/lib/action_policy/ext/policy_cache_key.rb +15 -33
  12. data/lib/action_policy/ext/{symbol_classify.rb → symbol_camelize.rb} +6 -6
  13. data/lib/action_policy/i18n.rb +1 -1
  14. data/lib/action_policy/lookup_chain.rb +41 -21
  15. data/lib/action_policy/policy/aliases.rb +7 -12
  16. data/lib/action_policy/policy/authorization.rb +14 -17
  17. data/lib/action_policy/policy/cache.rb +34 -18
  18. data/lib/action_policy/policy/core.rb +25 -12
  19. data/lib/action_policy/policy/defaults.rb +3 -9
  20. data/lib/action_policy/policy/execution_result.rb +3 -9
  21. data/lib/action_policy/policy/pre_check.rb +19 -58
  22. data/lib/action_policy/policy/reasons.rb +30 -20
  23. data/lib/action_policy/policy/scoping.rb +5 -6
  24. data/lib/action_policy/rails/controller.rb +6 -1
  25. data/lib/action_policy/rails/ext/active_record.rb +7 -0
  26. data/lib/action_policy/rails/policy/instrumentation.rb +1 -1
  27. data/lib/action_policy/rspec/be_authorized_to.rb +5 -9
  28. data/lib/action_policy/rspec/dsl.rb +3 -3
  29. data/lib/action_policy/rspec/have_authorized_scope.rb +5 -7
  30. data/lib/action_policy/testing.rb +1 -1
  31. data/lib/action_policy/utils/pretty_print.rb +21 -24
  32. data/lib/action_policy/utils/suggest_message.rb +1 -3
  33. data/lib/action_policy/version.rb +1 -1
  34. data/lib/generators/action_policy/install/templates/{application_policy.rb → application_policy.rb.tt} +1 -1
  35. data/lib/generators/action_policy/policy/policy_generator.rb +4 -1
  36. data/lib/generators/action_policy/policy/templates/{policy.rb → policy.rb.tt} +0 -0
  37. data/lib/generators/rspec/templates/{policy_spec.rb → policy_spec.rb.tt} +0 -0
  38. data/lib/generators/test_unit/templates/{policy_test.rb → policy_test.rb.tt} +0 -0
  39. metadata +30 -119
  40. data/.gitattributes +0 -2
  41. data/.github/FUNDING.yml +0 -1
  42. data/.github/ISSUE_TEMPLATE.md +0 -18
  43. data/.github/PULL_REQUEST_TEMPLATE.md +0 -29
  44. data/.gitignore +0 -15
  45. data/.rubocop.yml +0 -54
  46. data/.tidelift.yml +0 -6
  47. data/.travis.yml +0 -31
  48. data/Gemfile +0 -22
  49. data/Rakefile +0 -27
  50. data/action_policy.gemspec +0 -44
  51. data/benchmarks/namespaced_lookup_cache.rb +0 -71
  52. data/bin/console +0 -14
  53. data/bin/setup +0 -8
  54. data/docs/.nojekyll +0 -0
  55. data/docs/CNAME +0 -1
  56. data/docs/README.md +0 -77
  57. data/docs/_sidebar.md +0 -27
  58. data/docs/aliases.md +0 -122
  59. data/docs/assets/docsify-search.js +0 -364
  60. data/docs/assets/docsify.min.js +0 -3
  61. data/docs/assets/fonts/FiraCode-Medium.woff +0 -0
  62. data/docs/assets/fonts/FiraCode-Regular.woff +0 -0
  63. data/docs/assets/images/banner.png +0 -0
  64. data/docs/assets/images/cache.png +0 -0
  65. data/docs/assets/images/cache.svg +0 -70
  66. data/docs/assets/images/layer.png +0 -0
  67. data/docs/assets/images/layer.svg +0 -35
  68. data/docs/assets/prism-ruby.min.js +0 -1
  69. data/docs/assets/styles.css +0 -347
  70. data/docs/assets/vue.min.css +0 -1
  71. data/docs/authorization_context.md +0 -92
  72. data/docs/behaviour.md +0 -113
  73. data/docs/caching.md +0 -273
  74. data/docs/controller_action_aliases.md +0 -109
  75. data/docs/custom_lookup_chain.md +0 -48
  76. data/docs/custom_policy.md +0 -53
  77. data/docs/debugging.md +0 -55
  78. data/docs/decorators.md +0 -27
  79. data/docs/favicon.ico +0 -0
  80. data/docs/graphql.md +0 -302
  81. data/docs/i18n.md +0 -44
  82. data/docs/index.html +0 -43
  83. data/docs/instrumentation.md +0 -84
  84. data/docs/lookup_chain.md +0 -17
  85. data/docs/namespaces.md +0 -77
  86. data/docs/non_rails.md +0 -28
  87. data/docs/pre_checks.md +0 -57
  88. data/docs/pundit_migration.md +0 -80
  89. data/docs/quick_start.md +0 -118
  90. data/docs/rails.md +0 -120
  91. data/docs/reasons.md +0 -120
  92. data/docs/scoping.md +0 -255
  93. data/docs/testing.md +0 -333
  94. data/docs/writing_policies.md +0 -107
  95. data/gemfiles/jruby.gemfile +0 -8
  96. data/gemfiles/rails42.gemfile +0 -8
  97. data/gemfiles/rails6.gemfile +0 -8
  98. data/gemfiles/railsmaster.gemfile +0 -6
  99. data/lib/action_policy/ext/string_match.rb +0 -14
  100. data/lib/action_policy/ext/yield_self_then.rb +0 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dadd0bd9a76357e15ca389c572fcf3bdc3f78c56482652d364a08015e4b5c7a
4
- data.tar.gz: e38e115067ad978de53354ad29fd378e04871fd05b9853c2123c8d2514ea5f04
3
+ metadata.gz: 4fc0130963013d2a27c7abf48817dba07345f15fde792a1d9b55633de820c318
4
+ data.tar.gz: 238306ff0b289bbe89e69c7805c57cee46d1f1bfb89479bc35b34c801dad6994
5
5
  SHA512:
6
- metadata.gz: 2036718d582c6a55fe8ad1242b9971c1563e9a83673f7ae608f818c2930409ac32bb43517e28847916a02c3aaa75f927c8bf9be05b8893e0ceb163e5dbbf4c1e
7
- data.tar.gz: c90eb2088ce0ea1c1b6271f5c8fa03757f720294521f7ad6c70224ac79bb0a474e6b1a57c6d2f0f458cc3073085a052ed81dde61ece1ca797fc21a3e118b786a
6
+ metadata.gz: 192f5beabda0c3d0ad49deee958107b919e50eb1dc20e79df3fc96f8ee59f274eedb93e96f4d18614a58dc3df57b4f363ec360d40c3dfe42a2d0b2fca0eb6f81
7
+ data.tar.gz: ce790734997fbb3f6ac38bf9dea4aee0fd9a5c6dbe8442bb48fe2724f6e77574823d512444f398a5a2ad06b5b302d1a8ac031e50a62ea13830e6c38f2f75cd60
@@ -2,278 +2,340 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.5.0 (2020-09-29)
6
+
7
+ - Move `deny!` / `allow!` to core. ([@palkan][])
8
+
9
+ Now you can call `deny!` and `allow!` in policy rules to fail- or pass-fast.
10
+
11
+ **BREAKING.** Pre-check name is no longer added automatically to failure reasons. You should specify the reason
12
+ explicitly: `deny!(:my_reason)`.
13
+
14
+ - Add `Result#all_details` to return all collected details in a single hash. ([@palkan][])
15
+
16
+ - Add `default` option to lookup and `default_authorization_policy_class` callback to behaviour. ([@palkan][])
17
+
18
+ - Add `skip_verify_authorized!` to Rails controllers integration. ([@palkan][])
19
+
20
+ This method allows you to skip the `verify_authorized` callback dynamically.
21
+
22
+ - **Drop Ruby 2.4 support**. ([@palkan][])
23
+
24
+ - Add `allowance_to` method to authorization behaviour. ([@palkan][])
25
+
26
+ This method is similar to `allowed_to?` but returns an authorization result object.
27
+
28
+ - Support aliases in `allowed_to?` / `check?` calls within policies. ([@palkan][])
29
+
30
+ ## 0.4.5 (2020-07-29)
31
+
32
+ - Add strict_namespace option to lookup chain. (@rainerborene)
33
+
34
+ ## 0.4.4 (2020-07-07)
35
+
36
+ - Fix symbol lookup with namespaces. ([@palkan][])
37
+
38
+ Fixes [#122](https://github.com/palkan/action_policy/issues/122).
39
+
40
+ - Separated `#classify`-based and `#camelize`-based symbol lookups. ([Be-ngt-oH][])
41
+
42
+ Only affects Rails apps. Now lookup for `:users` tries to find `UsersPolicy` first (camelize),
43
+ and only then search for `UserPolicy` (classify).
44
+
45
+ See [PR#118](https://github.com/palkan/action_policy/pull/118).
46
+
47
+ - Fix calling rules with `allowed_to?` directly. ([@palkan][])
48
+
49
+ Fixes [#113](https://github.com/palkan/action_policy/issues/113)
50
+
51
+ ## 0.4.3 (2019-12-14)
52
+
53
+ - Add `#cache(*parts, **options) { ... }` method. ([@palkan][])
54
+
55
+ Allows you to cache anything in policy classes using the Action Policy
56
+ cache key generation mechanism.
57
+
58
+ - Handle versioned Rails cache keys. ([@palkan][])
59
+
60
+ Use `#cache_with_version` as a cache key if defined.
61
+
62
+ ## 0.4.2 (2019-12-13)
63
+
64
+ - Fix regression introduced in 0.4.0 which broke testing Class targets. ([@palkan][])
65
+
5
66
  ## 0.4.0 (2019-12-11)
6
67
 
7
68
  - Add `action_policy.init` instrumentation event. ([@palkan][])
8
69
 
9
- Triggered every time a new policy object is initialized.
70
+ Triggered every time a new policy object is initialized.
10
71
 
11
72
  - Fix policy memoization with explicit context. ([@palkan][])
12
73
 
13
- Explicit context (`authorize! context: {}`) wasn't considered during
14
- policies memoization. Not this is fixed.
74
+ Explicit context (`authorize! context: {}`) wasn't considered during
75
+ policies memoization. Not this is fixed.
15
76
 
16
77
  - Support composed matchers for authorization target testing. ([@palkan][])
17
78
 
18
- Now you can write tests like this:
79
+ Now you can write tests like this:
19
80
 
20
- ```ruby
21
- expect { subject }.to be_authorized_to(:show?, an_instance_of(User))
22
- ```
81
+ ```ruby
82
+ expect { subject }.to be_authorized_to(:show?, an_instance_of(User))
83
+ ```
23
84
 
24
85
  ## 0.3.4 (2019-11-27)
25
86
 
26
87
  - Fix Rails generators. ([@palkan][])
27
88
 
28
- Only invoke install generator if `application_policy.rb` is missing.
29
- Fix hooking into test frameworks.
89
+ Only invoke install generator if `application_policy.rb` is missing.
90
+ Fix hooking into test frameworks.
30
91
 
31
92
  ## 0.3.3 (2019-11-27)
32
93
 
33
94
  - Improve pretty print functionality. ([@palkan][])
34
95
 
35
- Colorize true/false values.
36
- Handle multiline expressions and debug statements (i.e., `binding.pry`).
96
+ Colorize true/false values.
97
+ Handle multiline expressions and debug statements (i.e., `binding.pry`).
37
98
 
38
99
  - Add Rails generators. ([@nicolas-brousse][])
39
100
 
40
- Adds `action_policy:install` and `action_policy:policy MODEL` Rails generators.
101
+ Adds `action_policy:install` and `action_policy:policy MODEL` Rails generators.
41
102
 
42
103
  - Optional authorization target. ([@somenugget][])
43
104
 
44
- Allows making authorization context optional:
105
+ Allows making authorization context optional:
45
106
 
46
- ```ruby
47
- class OptionalRolePolicy < ActionPolicy::Base
48
- authorize :role, optional: true
49
- end
107
+ ```ruby
108
+ class OptionalRolePolicy < ActionPolicy::Base
109
+ authorize :role, optional: true
110
+ end
50
111
 
51
- policy = OptionalRolePolicy.new
52
- policy.role #=> nil
53
- ```
112
+ policy = OptionalRolePolicy.new
113
+ policy.role #=> nil
114
+ ```
54
115
 
55
116
  ## 0.3.2 (2019-05-26) 👶
56
117
 
57
118
  - Fixed thread-safety issues with scoping configs. ([@palkan][])
58
119
 
59
- Fixes [#75](https://github.com/palkan/action_policy/issues/75).
120
+ Fixes [#75](https://github.com/palkan/action_policy/issues/75).
60
121
 
61
122
  ## 0.3.1 (2019-05-30)
62
123
 
63
124
  - Fixed bug with missing implicit target and hash like scoping data. ([@palkan][])
64
125
 
65
- Fixes [#70](https://github.com/palkan/action_policy/issues/70).
126
+ Fixes [#70](https://github.com/palkan/action_policy/issues/70).
66
127
 
67
128
  ## 0.3.0 (2019-04-02)
68
129
 
69
130
  - Added ActiveSupport-based instrumentation. ([@palkan][])
70
131
 
71
- See [PR#4](https://github.com/palkan/action_policy/pull/4)
132
+ See [PR#4](https://github.com/palkan/action_policy/pull/4)
72
133
 
73
134
  - Allow passing authorization context explicitly. ([@palkan][])
74
135
 
75
- Closes [#3](https://github.com/palkan/action_policy/issues/3).
136
+ Closes [#3](https://github.com/palkan/action_policy/issues/3).
76
137
 
77
- Now it's possible to override implicit authorization context
78
- via `context` option:
138
+ Now it's possible to override implicit authorization context
139
+ via `context` option:
79
140
 
80
- ```ruby
81
- authorize! target, to: :show?, context: {user: another_user}
82
- authorized_scope User.all, context: {user: another_user}
83
- ```
141
+ ```ruby
142
+ authorize! target, to: :show?, context: {user: another_user}
143
+ authorized_scope User.all, context: {user: another_user}
144
+ ```
84
145
 
85
146
  - Renamed `#authorized` to `#authorized_scope`. ([@palkan][])
86
147
 
87
- **NOTE:** `#authorized` alias is also available.
148
+ **NOTE:** `#authorized` alias is also available.
88
149
 
89
150
  - Added `Policy#pp(rule)` method to print annotated rule source code. ([@palkan][])
90
151
 
91
- Example (debugging):
152
+ Example (debugging):
92
153
 
93
- ```ruby
94
- def edit?
95
- binding.pry # rubocop:disable Lint/Debugger
96
- (user.name == "John") && (admin? || access_feed?)
97
- end
98
- ```
99
-
100
- ```sh
101
- pry> pp :edit?
102
- MyPolicy#edit?
103
- ↳ (
104
- user.name == "John" #=> false
105
- )
106
- AND
107
- (
108
- admin? #=> false
109
- OR
110
- access_feed? #=> true
111
- )
154
+ ```ruby
155
+ def edit?
156
+ binding.pry # rubocop:disable Lint/Debugger
157
+ (user.name == "John") && (admin? || access_feed?)
158
+ end
159
+ ```
160
+
161
+ ```sh
162
+ pry> pp :edit?
163
+ MyPolicy#edit?
164
+ ↳ (
165
+ user.name == "John" #=> false
112
166
  )
113
- ```
167
+ AND
168
+ (
169
+ admin? #=> false
170
+ OR
171
+ access_feed? #=> true
172
+ )
173
+ )
174
+ ```
114
175
 
115
- See [PR#63](https://github.com/palkan/action_policy/pull/63)
176
+ See [PR#63](https://github.com/palkan/action_policy/pull/63)
116
177
 
117
178
  - Added ability to provide additional failure reasons details. ([@palkan][])
118
179
 
119
- Example:
180
+ Example:
120
181
 
121
- ```ruby
122
- class ApplicantPolicy < ApplicationPolicy
123
- def show?
124
- allowed_to?(:show?, object.stage)
125
- end
182
+ ```ruby
183
+ class ApplicantPolicy < ApplicationPolicy
184
+ def show?
185
+ allowed_to?(:show?, object.stage)
126
186
  end
127
-
128
- class StagePolicy < ApplicationPolicy
129
- def show?
130
- # Add stage title to the failure reason (if any)
131
- # (could be used by client to show more descriptive message)
132
- details[:title] = record.title
133
- # then perform the checks
134
- user.stages.where(id: record.id).exists?
135
- end
187
+ end
188
+
189
+ class StagePolicy < ApplicationPolicy
190
+ def show?
191
+ # Add stage title to the failure reason (if any)
192
+ # (could be used by client to show more descriptive message)
193
+ details[:title] = record.title
194
+ # then perform the checks
195
+ user.stages.where(id: record.id).exists?
136
196
  end
197
+ end
137
198
 
138
- # when accessing the reasons
139
- p ex.result.reasons.details #=> { stage: [{show?: {title: "Onboarding"}] }
140
- ```
199
+ # when accessing the reasons
200
+ p ex.result.reasons.details #=> { stage: [{show?: {title: "Onboarding"}] }
201
+ ```
141
202
 
142
- See https://github.com/palkan/action_policy/pull/58
203
+ See https://github.com/palkan/action_policy/pull/58
143
204
 
144
205
  - Ruby 2.4+ is required. ([@palkan][])
145
206
 
146
207
  - Added RSpec DSL for writing policy specs. ([@palkan])
147
208
 
148
- The goal of this DSL is to reduce the boilerplate when writing
149
- policies specs.
209
+ The goal of this DSL is to reduce the boilerplate when writing
210
+ policies specs.
150
211
 
151
- Example:
212
+ Example:
152
213
 
153
- ```ruby
154
- describe PostPolicy do
155
- let(:user) { build_stubbed :user }
156
- let(:record) { build_stubbed :post, draft: false }
214
+ ```ruby
215
+ describe PostPolicy do
216
+ let(:user) { build_stubbed :user }
217
+ let(:record) { build_stubbed :post, draft: false }
157
218
 
158
- let(:context) { {user: user} }
219
+ let(:context) { {user: user} }
159
220
 
160
- describe_rule :show? do
161
- succeed "when post is published"
221
+ describe_rule :show? do
222
+ succeed "when post is published"
162
223
 
163
- failed "when post is draft" do
164
- before { post.draft = false }
224
+ failed "when post is draft" do
225
+ before { post.draft = false }
165
226
 
166
- succeed "when user is a manager" do
167
- before { user.role = "manager" }
168
- end
227
+ succeed "when user is a manager" do
228
+ before { user.role = "manager" }
169
229
  end
170
230
  end
171
231
  end
172
- ```
232
+ end
233
+ ```
173
234
 
174
235
  - Added I18n support ([@DmitryTsepelev][])
175
236
 
176
- Example:
237
+ Example:
177
238
 
178
- ```ruby
179
- class ApplicationController < ActionController::Base
180
- rescue_from ActionPolicy::Unauthorized do |ex|
181
- p ex.result.message #=> "You do not have access to the stage"
182
- p ex.result.reasons.full_messages #=> ["You do not have access to the stage"]
183
- end
239
+ ```ruby
240
+ class ApplicationController < ActionController::Base
241
+ rescue_from ActionPolicy::Unauthorized do |ex|
242
+ p ex.result.message #=> "You do not have access to the stage"
243
+ p ex.result.reasons.full_messages #=> ["You do not have access to the stage"]
184
244
  end
185
- ```
245
+ end
246
+ ```
186
247
 
187
248
  - Added scope options to scopes. ([@korolvs][])
188
249
 
189
- See [#47](https://github.com/palkan/action_policy/pull/47).
250
+ See [#47](https://github.com/palkan/action_policy/pull/47).
190
251
 
191
- Example:
192
- ```ruby
193
- # users_controller.rb
194
- class UsersController < ApplicationController
195
- def index
196
- @user = authorized(User.all, scope_options: {with_deleted: true})
197
- end
252
+ Example:
253
+
254
+ ```ruby
255
+ # users_controller.rb
256
+ class UsersController < ApplicationController
257
+ def index
258
+ @user = authorized(User.all, scope_options: {with_deleted: true})
198
259
  end
260
+ end
199
261
 
200
- # user_policy.rb
201
- describe UserPolicy < Application do
202
- relation_scope do |relation, with_deleted: false|
203
- rel = some_logic(relation)
204
- with_deleted ? rel.with_deleted : rel
205
- end
262
+ # user_policy.rb
263
+ describe UserPolicy < Application do
264
+ relation_scope do |relation, with_deleted: false|
265
+ rel = some_logic(relation)
266
+ with_deleted ? rel.with_deleted : rel
206
267
  end
207
- ```
268
+ end
269
+ ```
208
270
 
209
271
  - Added Symbol lookup to the lookup chain ([@DmitryTsepelev][])
210
272
 
211
- For instance, lookup will implicitly use `AdminPolicy` in a following case:
273
+ For instance, lookup will implicitly use `AdminPolicy` in a following case:
212
274
 
213
- ```ruby
214
- # admin_controller.rb
215
- class AdminController < ApplicationController
216
- authorize! :admin, to: :update_settings
217
- end
218
- ```
275
+ ```ruby
276
+ # admin_controller.rb
277
+ class AdminController < ApplicationController
278
+ authorize! :admin, to: :update_settings
279
+ end
280
+ ```
219
281
 
220
282
  - Added testing for scopes. ([@palkan][])
221
283
 
222
- Example:
284
+ Example:
223
285
 
224
- ```ruby
225
- # users_controller.rb
226
- class UsersController < ApplicationController
227
- def index
228
- @user = authorized(User.all)
229
- end
286
+ ```ruby
287
+ # users_controller.rb
288
+ class UsersController < ApplicationController
289
+ def index
290
+ @user = authorized(User.all)
230
291
  end
231
-
232
- # users_controller_spec.rb
233
- describe UsersController do
234
- subject { get :index }
235
- it "has authorized scope" do
236
- expect { subject }.to have_authorized_scope(:active_record_relation)
237
- .with(PostPolicy)
238
- end
292
+ end
293
+
294
+ # users_controller_spec.rb
295
+ describe UsersController do
296
+ subject { get :index }
297
+ it "has authorized scope" do
298
+ expect { subject }.to have_authorized_scope(:active_record_relation)
299
+ .with(PostPolicy)
239
300
  end
240
- ```
301
+ end
302
+ ```
241
303
 
242
304
  - Added scoping support. ([@palkan][])
243
305
 
244
- See [#5](https://github.com/palkan/action_policy/issues/5).
306
+ See [#5](https://github.com/palkan/action_policy/issues/5).
245
307
 
246
- By "scoping" we mean an ability to use policies to _scope data_.
308
+ By "scoping" we mean an ability to use policies to _scope data_.
247
309
 
248
- For example, when you want to _scope_ Active Record collections depending
249
- on the current user permissions:
310
+ For example, when you want to _scope_ Active Record collections depending
311
+ on the current user permissions:
250
312
 
251
- ```ruby
252
- class PostsController < ApplicationController
253
- def index
254
- @posts = authorized(Post.all)
255
- end
313
+ ```ruby
314
+ class PostsController < ApplicationController
315
+ def index
316
+ @posts = authorized(Post.all)
256
317
  end
318
+ end
257
319
 
258
- class PostPolicy < ApplicationPolicy
259
- relation_scope do |relation|
260
- next relation if user.admin?
261
- relation.where(user: user)
262
- end
320
+ class PostPolicy < ApplicationPolicy
321
+ relation_scope do |relation|
322
+ next relation if user.admin?
323
+ relation.where(user: user)
263
324
  end
264
- ```
325
+ end
326
+ ```
265
327
 
266
- Action Policy provides a flexible mechanism to apply scopes to anything you want.
328
+ Action Policy provides a flexible mechanism to apply scopes to anything you want.
267
329
 
268
- Read more in [docs](https://actionpolicy.evilmartians.io/).
330
+ Read more in [docs](https://actionpolicy.evilmartians.io/).
269
331
 
270
332
  - Added `#implicit_authorization_target`. ([@palkan][]).
271
333
 
272
- See [#35](https://github.com/palkan/action_policy/issues/35).
334
+ See [#35](https://github.com/palkan/action_policy/issues/35).
273
335
 
274
- Implicit authorization target (defined by `implicit_authorization_target`) is used when no target specified for `authorize!` call.
336
+ Implicit authorization target (defined by `implicit_authorization_target`) is used when no target specified for `authorize!` call.
275
337
 
276
- For example, for Rails controllers integration it's just `controller_name.classify.safe_constantize`.
338
+ For example, for Rails controllers integration it's just `controller_name.classify.safe_constantize`.
277
339
 
278
340
  - Consider `record#policy_name` when looking up for a policy class. ([@palkan][])
279
341
 
@@ -287,21 +349,21 @@
287
349
 
288
350
  - Add ability to disable per-thread cache and disable it in test env by default. ([@palkan][])
289
351
 
290
- You can control per-thread cache by setting:
352
+ You can control per-thread cache by setting:
291
353
 
292
- ```ruby
293
- ActionPolicy::PerThreadCache.enabled = true # or false
294
- ```
354
+ ```ruby
355
+ ActionPolicy::PerThreadCache.enabled = true # or false
356
+ ```
295
357
 
296
358
  ## 0.2.3 (2018-07-03)
297
359
 
298
360
  - [Fix [#16](https://github.com/palkan/action_policy/issues/16)] Add ability to disable namespace resolution cache. ([@palkan][])
299
361
 
300
- We cache namespaced policy resolution for better performance (it could affect performance when we look up a policy from a deeply nested module context).
362
+ We cache namespaced policy resolution for better performance (it could affect performance when we look up a policy from a deeply nested module context).
301
363
 
302
- It could be disabled by setting `ActionPolicy::LookupChain.namespace_cache_enabled = false`. It's enabled by default unless `RACK_ENV` env var is specified and is not equal to `"production"` (e.g. when `RACK_ENV=test` the cache is disabled).
364
+ It could be disabled by setting `ActionPolicy::LookupChain.namespace_cache_enabled = false`. It's enabled by default unless `RACK_ENV` env var is specified and is not equal to `"production"` (e.g. when `RACK_ENV=test` the cache is disabled).
303
365
 
304
- When using Rails it's enabled only in production mode but could be configured through setting the `config.action_policy.namespace_cache_enabled` parameter.
366
+ When using Rails it's enabled only in production mode but could be configured through setting the `config.action_policy.namespace_cache_enabled` parameter.
305
367
 
306
368
  - [Fix [#18](https://github.com/palkan/action_policy/issues/18)] Clarify documentation around, and fix the way `resolve_rule` resolves rules and rule aliases when subclasses are involved. ([@brendon][])
307
369
 
@@ -309,11 +371,10 @@
309
371
 
310
372
  - [Fix [#29](https://github.com/palkan/action_policy/issues/29)] Fix loading cache middleware. ([@palkan][])
311
373
 
312
-
313
374
  - Use `send` instead of `public_send` to get the `authorization_context` so that contexts such as
314
375
  `current_user` can be `private` in the controller. ([@brendon][])
315
376
 
316
- - Fix railtie initialisation for Rails < 5. ([@brendon][])
377
+ - Fix railtie initialization for Rails < 5. ([@brendon][])
317
378
 
318
379
  ## 0.2.1 (yanked)
319
380
 
@@ -323,18 +384,18 @@
323
384
 
324
385
  - Add `reasons.details`. ([@palkan][])
325
386
 
326
- ```ruby
327
- rescue_from ActionPolicy::Unauthorized do |ex|
328
- ex.result.reasons.details #=> { stage: [:show?] }
329
- end
330
- ```
387
+ ```ruby
388
+ rescue_from ActionPolicy::Unauthorized do |ex|
389
+ ex.result.reasons.details #=> { stage: [:show?] }
390
+ end
391
+ ```
331
392
 
332
393
  - Add `ExecutionResult`. ([@palkan][])
333
394
 
334
- ExecutionResult contains all the rule application artifacts: the result (`true` / `false`),
335
- failures reasons.
395
+ ExecutionResult contains all the rule application artifacts: the result (`true` / `false`),
396
+ failures reasons.
336
397
 
337
- This value is now stored in a cache (if any) instead of just the call result (`true` / `false`).
398
+ This value is now stored in a cache (if any) instead of just the call result (`true` / `false`).
338
399
 
339
400
  - Add `Policy.identifier`. ([@palkan][])
340
401
 
@@ -367,3 +428,4 @@
367
428
  [@korolvs]: https://github.com/korolvs
368
429
  [@nicolas-brousse]: https://github.com/nicolas-brousse
369
430
  [@somenugget]: https://github.com/somenugget
431
+ [@Be-ngt-oH]: https://github.com/Be-ngt-oH