passpartu 1.2.0 → 1.2.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: 1a282e26dea8142a8ad36151367612a9bfbc3ad0e4c116d87343e93f7e8301a9
4
- data.tar.gz: 0dc7b495c6b574a3ca83328e1014e948cbf2993b9fe97cbed192cfb0756b91a6
3
+ metadata.gz: 172ad6a276a5b27cafa024e776e3363de78b82fc5606e9f2eb92689323898269
4
+ data.tar.gz: 1e343e86551faab902c18eee6faaa9ee85cea5980102a1bd2448f1e4f23abbbf
5
5
  SHA512:
6
- metadata.gz: 73f3c5177366551d7101dd0873e17c6f13dd76b5fb682c0b6b55f07514c9329c728f4e1c5f83c136c7875f5b59968278ad86707010a8b5874b5f4ffdcc386071
7
- data.tar.gz: 43ac9dcdc2d90c3db00e781277abdd544a748cab17a2548de57a6d206d1605302cf93e7a9ab90ddb390f90a2bd8878d92663fd363c99017f4bbe3bc4444f90c8
6
+ metadata.gz: 8b0cbed99bb314138bb993f303d7f1eed70e2160fd051d7eb358252dcb80c4accc3059c029bc5fcc297a80feb498eb6bfcc34c9d3a7ca41377240e71b2b0c621
7
+ data.tar.gz: 5c65e2c58397b1ce5f80e2cdc7c6d3e4bc0aca4746f536444c05bb4ec29ed48eefc98ef63a9d13d32d474524f3d47afa0dc50874291826eb76640856dc0b6890
@@ -15,7 +15,6 @@ module Passpartu
15
15
  end
16
16
 
17
17
  def call
18
- phash = respond_to?(:policy_hash) ? {} : Passpartu.policy
19
18
  role_method = Passpartu.config.role_access_method
20
19
 
21
20
  klass.class_eval do
@@ -26,12 +25,12 @@ module Passpartu
26
25
  only: only,
27
26
  except: except,
28
27
  skip: skip,
29
- policy_hash: phash,
28
+ policy_hash: -> { respond_to?(:policy_hash) ? policy_hash : Passpartu.policy }.call,
30
29
  &block
31
30
  )
32
31
  end
33
32
 
34
- phash.each_key do |policy_role|
33
+ Passpartu.policy.each_key do |policy_role|
35
34
  define_method("#{policy_role}_can?") do |*keys, only: nil, except: nil, skip: nil, &block|
36
35
  send(role_method).to_s == policy_role &&
37
36
  Passpartu::BlockVerify.call(
@@ -40,7 +39,7 @@ module Passpartu
40
39
  only: only,
41
40
  except: except,
42
41
  skip: skip,
43
- policy_hash: phash,
42
+ policy_hash: -> { respond_to?(:policy_hash) ? policy_hash : Passpartu.policy }.call,
44
43
  &block
45
44
  )
46
45
  end
@@ -47,7 +47,7 @@ module Passpartu
47
47
  end
48
48
 
49
49
  def default_check
50
- @result = policy_hash.dig(role, *keys)
50
+ @result = policy_hash.has_key?(role) ? policy_hash.dig(role, *keys) : policy_hash.dig(*keys)
51
51
  end
52
52
 
53
53
  def check_crud_if
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Passpartu
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.2'
5
5
  end
data/lib/passpartu.rb CHANGED
@@ -66,7 +66,17 @@ module Passpartu
66
66
  private
67
67
 
68
68
  def load_policy_file(path)
69
- RUBY_VERSION.to_f >= 3.1 ? YAML.load_file(path, aliases: true) : YAML.load_file(path)
69
+ yaml = File.read(path)
70
+
71
+ if RUBY_VERSION.to_f >= 3.1
72
+ YAML.safe_load(
73
+ yaml,
74
+ permitted_classes: [Symbol],
75
+ aliases: true
76
+ )
77
+ else
78
+ YAML.load_file(yaml)
79
+ end
70
80
  end
71
81
 
72
82
  def policy=(value)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passpartu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - OrestF
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2023-05-19 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bundler
@@ -130,7 +129,6 @@ homepage: https://github.com/coaxsoft/passpartu
130
129
  licenses:
131
130
  - MIT
132
131
  metadata: {}
133
- post_install_message:
134
132
  rdoc_options: []
135
133
  require_paths:
136
134
  - lib
@@ -145,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
143
  - !ruby/object:Gem::Version
146
144
  version: '0'
147
145
  requirements: []
148
- rubygems_version: 3.4.6
149
- signing_key:
146
+ rubygems_version: 3.6.7
150
147
  specification_version: 4
151
148
  summary: Passpartu makes policies great again
152
149
  test_files: []