action_authorization 0.3.2 → 0.3.4

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: b488de453a34ffee8f9f686af35f9a4221fed24ee7dea3a56475efc295b70f5a
4
- data.tar.gz: 384e891ca0486d7952121c45941eaea65eddae2e40812259da09a373358aba89
3
+ metadata.gz: 738c9014d3f4738e858d3fed5b026ddf9481f856b814421fe4a2bc7ddcd7c478
4
+ data.tar.gz: e3fcdc5d42fd8071f0b1c28260197f5dc5f7c748b3c4cd02f5968328e58818c4
5
5
  SHA512:
6
- metadata.gz: 6a2579a9fec0b4115fc9980b535f549fd1b5c31f9ca4180f57d1b7d726d72cb0b78caedd683fca501ffa10ce52e1cf1e873e429cb703e58e2a7d7c3cf57418a0
7
- data.tar.gz: 8c889dc5dd44b874a5d22a9b8b4225b4b5b7c5a8dc01530ac80df8c2fb31830e1115433a2f7d156bb12191430d9e73ddc214d26fe4209d0e88a5b944f776f6a4
6
+ metadata.gz: a658d363a670eb08452b23352519747317a8415fd49b6a90bd42c534619c441aa98f572a263f3fb731b67b627c32c62a9da190853216287873ab42bd90ee13a4
7
+ data.tar.gz: '0993d92a305756013707f6391e0368998f742675db8e96765905456b713a35deae8bfcf903df131f6a27d9245c7c091155620b53327236f7cc63da828cca1882'
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionAuthorization
4
+ class NullPolicy < BasePolicy
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionAuthorization
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.4"
5
5
  end
@@ -4,6 +4,7 @@ require "active_support/core_ext/module/delegation"
4
4
  require "active_support/core_ext/string/inflections"
5
5
  require "action_authorization/version"
6
6
  require "action_authorization/base_policy"
7
+ require "action_authorization/null_policy"
7
8
  require "action_authorization/authorization_failure"
8
9
 
9
10
  module ActionAuthorization
@@ -15,8 +16,8 @@ module ActionAuthorization
15
16
 
16
17
  protected
17
18
 
18
- def authorize(object, action: action_name, policy_class: nil)
19
- raise AuthorizationFailure unless policy(object, policy_class).public_send(:"#{action}?")
19
+ def authorize(object, action: action_name, policy_class: nil, **)
20
+ raise AuthorizationFailure unless policy(object, policy_class).public_send(:"#{action}?", **)
20
21
 
21
22
  object
22
23
  end
@@ -26,6 +27,6 @@ module ActionAuthorization
26
27
  end
27
28
 
28
29
  def policy_class_for(object)
29
- "#{object.model_name}Policy".constantize
30
+ object.nil? ? NullPolicy : "#{object.model_name}Policy".constantize
30
31
  end
31
32
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Baldwin
8
8
  - Brightways Learning
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-09-16 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
@@ -17,14 +16,14 @@ dependencies:
17
16
  requirements:
18
17
  - - ">="
19
18
  - !ruby/object:Gem::Version
20
- version: '5.0'
19
+ version: 7.1.0
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
24
  - - ">="
26
25
  - !ruby/object:Gem::Version
27
- version: '5.0'
26
+ version: 7.1.0
28
27
  description: A base policy class for authorizing controller actions with access to
29
28
  the current_user and object.
30
29
  email:
@@ -39,6 +38,7 @@ files:
39
38
  - lib/action_authorization.rb
40
39
  - lib/action_authorization/authorization_failure.rb
41
40
  - lib/action_authorization/base_policy.rb
41
+ - lib/action_authorization/null_policy.rb
42
42
  - lib/action_authorization/version.rb
43
43
  homepage: https://github.com/wwidea/action_authorization
44
44
  licenses:
@@ -46,7 +46,6 @@ licenses:
46
46
  metadata:
47
47
  homepage_uri: https://github.com/wwidea/action_authorization
48
48
  rubygems_mfa_required: 'true'
49
- post_install_message:
50
49
  rdoc_options: []
51
50
  require_paths:
52
51
  - lib
@@ -54,15 +53,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
53
  requirements:
55
54
  - - ">="
56
55
  - !ruby/object:Gem::Version
57
- version: 3.1.0
56
+ version: 3.3.0
58
57
  required_rubygems_version: !ruby/object:Gem::Requirement
59
58
  requirements:
60
59
  - - ">="
61
60
  - !ruby/object:Gem::Version
62
61
  version: '0'
63
62
  requirements: []
64
- rubygems_version: 3.5.11
65
- signing_key:
63
+ rubygems_version: 4.0.2
66
64
  specification_version: 4
67
65
  summary: Rails controller object-level action authorization.
68
66
  test_files: []