action_policy 0.6.1 → 0.6.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea35d16fad09b0ec03201b12ff0ff17b8a189fba92c2391ca88d4140e8561570
4
- data.tar.gz: 0decb11729d971bcf4fe3ef78b3fe461e42b61e5ed9c0b58fb6d3d9cdd2e8d48
3
+ metadata.gz: 491af624707f597ded52f7d1cacdfc07435937250370804c0ac374f436b494ce
4
+ data.tar.gz: 33ac6abf6907738c6fce67193659e4fdb6615a2dd78a375dba4b57060c9d8f6e
5
5
  SHA512:
6
- metadata.gz: 10048a5581c03d81ebb582c96bd7a168a800028d2d19783f44ce8837cb2747a1d80249195d0d4df090ebc34002f5ffde90edb5dc34e50765f61ed4c1782ac5ce
7
- data.tar.gz: e369370e68ba73cd6645c1b90ea7ede7e4d3b446aa582a77c7a417ccb95065ef06e3461b303317895835004dfbdcf5bacff58664dda7eafe71e09a691cc22c0f
6
+ metadata.gz: 54e1dffffae9777c07d47f5718143cfbc546d6d100e873aadc3a51a1e8821f6495a7d869a477ac7d9d65be1ef92e1fef8bb9adde6c5177186c63eebb8dc88a94
7
+ data.tar.gz: 2b866340538957aa93c5db05a9c8bc7181b9cc4b9b178a137b58a13ad0d7a5158904b911834ab5dd2cf5af4d29bca29d7003095144c7786583375ec8d273c0d5
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.6.2 (2022-08-12)
6
+
7
+ - Allow omitting authorization record if `with` is provided. ([@palkan][])
8
+
5
9
  ## 0.6.1 (2022-05-23)
6
10
 
7
11
  - Fix policy lookup when a namespaced record is passed and the strict mode is used. ([@palkan][])
@@ -58,10 +58,11 @@ module ActionPolicy
58
58
  end
59
59
 
60
60
  def authorization_context
61
- return @__authorization_context if
62
- instance_variable_defined?(:@__authorization_context)
61
+ @_authorization_context ||= build_authorization_context
62
+ end
63
63
 
64
- @__authorization_context = self.class.authorization_targets
64
+ def build_authorization_context
65
+ self.class.authorization_targets
65
66
  .each_with_object({}) do |(key, meth), obj|
66
67
  obj[key] = send(meth)
67
68
  end
@@ -73,11 +74,19 @@ module ActionPolicy
73
74
  policy.resolve_rule(rule)
74
75
  end
75
76
 
76
- def lookup_authorization_policy(record, **options) # :nodoc:
77
- record = implicit_authorization_target! if :__undef__ == record # rubocop:disable Style/YodaCondition See https://github.com/palkan/action_policy/pull/180
78
- Kernel.raise ArgumentError, "Record must be specified" if record.nil?
77
+ def lookup_authorization_policy(record, with: nil, **options) # :nodoc:
78
+ if record == :__undef__
79
+ record =
80
+ if with
81
+ implicit_authorization_target
82
+ else
83
+ implicit_authorization_target!
84
+ end
85
+ end
86
+
87
+ Kernel.raise ArgumentError, "Record or policy must be specified" if record.nil? && with.nil?
79
88
 
80
- policy_for(record: record, **options)
89
+ policy_for(record: record, with: with, **options)
81
90
  end
82
91
 
83
92
  module ClassMethods # :nodoc:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionPolicy
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_policy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-24 00:00:00.000000000 Z
11
+ date: 2022-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-next-core
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  - !ruby/object:Gem::Version
242
242
  version: '0'
243
243
  requirements: []
244
- rubygems_version: 3.3.7
244
+ rubygems_version: 3.3.11
245
245
  signing_key:
246
246
  specification_version: 4
247
247
  summary: Authorization framework for Ruby/Rails application