action_authorization 0.3.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54416a7e815288367cea967a9198f197cc2fe10e76e35fcac702406c8b5f8215
4
- data.tar.gz: 6097c18236273bf1ebce5439813ae6383805a2a66f264321fac402d64792aa2d
3
+ metadata.gz: d6ec2bb21ab2cd6e7a6fc961076931ba385d327272437427e2653f07dabd0901
4
+ data.tar.gz: 6b01e8b343d8fc465e9ad5c36bf76f515ca7f1b809bfc28f2ba4f66d106f6d5c
5
5
  SHA512:
6
- metadata.gz: e3274dbb63f416cd663a7f47f817d7551fe3abdabaa222d0c067c2fad8e7503a074347a469a43c311c018b949d5bff0bbc36253381d38dc045ac92288295a7d1
7
- data.tar.gz: f6fb7dbb58d0933b4c96623093fda6c8b902b5af769b2c2298ac35e053e39da9a659ea8bc86c8d1b4bb3b3d5ad188a7e4894c3f7a8603cb4f38fb7d56f5bdc61
6
+ metadata.gz: d91740824f6f3aca60f1c98de4ac7fea9e3e231e710e1ce027465cb8908596264885710c0d3b3ca98d8cd877d26d9ef83a3d1c6848624aa171f2bedc0798fe52
7
+ data.tar.gz: 8f6b3b6a14ba8533f6361aa1cd1241141ee246ee1561098cfa88fba41b53d64124be783a4a45ec01b4ef95fe2f3628b327b17f4171652be16e4e8d33bb775d4a
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/setup"
2
4
 
3
5
  require "bundler/gem_tasks"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionAuthorization
2
4
  class AuthorizationFailure < StandardError
3
5
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionAuthorization
2
4
  class BasePolicy
3
5
  attr_accessor :user, :object
4
6
 
5
7
  def self.type
6
- name.gsub('Policy', '')
8
+ name.delete_suffix("Policy")
7
9
  end
8
10
 
9
11
  def self.type_class
@@ -21,6 +23,7 @@ module ActionAuthorization
21
23
 
22
24
  # create alias to object from subclass name
23
25
  def self.inherited(klass)
26
+ super
24
27
  klass.send(:alias_method, klass.type.underscore, :object)
25
28
  end
26
29
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActionAuthorization
2
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/module/delegation"
2
4
  require "active_support/core_ext/string/inflections"
3
5
  require "action_authorization/version"
@@ -14,11 +16,9 @@ module ActionAuthorization
14
16
  protected
15
17
 
16
18
  def authorize(object, action: action_name, policy_class: nil)
17
- if policy(object, policy_class).send("#{action}?")
18
- object
19
- else
20
- raise ActionAuthorization::AuthorizationFailure
21
- end
19
+ raise AuthorizationFailure unless policy(object, policy_class).public_send(:"#{action}?")
20
+
21
+ object
22
22
  end
23
23
 
24
24
  def policy(object, policy_class = nil)
@@ -26,6 +26,6 @@ module ActionAuthorization
26
26
  end
27
27
 
28
28
  def policy_class_for(object)
29
- "#{object.class.name}Policy".constantize
29
+ "#{object.model_name}Policy".constantize
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Baldwin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-30 00:00:00.000000000 Z
12
+ date: 2024-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -45,7 +45,6 @@ licenses:
45
45
  - MIT
46
46
  metadata:
47
47
  homepage_uri: https://github.com/wwidea/action_authorization
48
- source_code_uri: https://github.com/wwidea/action_authorization
49
48
  rubygems_mfa_required: 'true'
50
49
  post_install_message:
51
50
  rdoc_options: []
@@ -55,14 +54,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
55
54
  requirements:
56
55
  - - ">="
57
56
  - !ruby/object:Gem::Version
58
- version: 2.7.0
57
+ version: 3.1.0
59
58
  required_rubygems_version: !ruby/object:Gem::Requirement
60
59
  requirements:
61
60
  - - ">="
62
61
  - !ruby/object:Gem::Version
63
62
  version: '0'
64
63
  requirements: []
65
- rubygems_version: 3.4.5
64
+ rubygems_version: 3.5.11
66
65
  signing_key:
67
66
  specification_version: 4
68
67
  summary: Rails controller object-level action authorization.