passpartu 1.2.0 → 1.2.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: 1a282e26dea8142a8ad36151367612a9bfbc3ad0e4c116d87343e93f7e8301a9
4
- data.tar.gz: 0dc7b495c6b574a3ca83328e1014e948cbf2993b9fe97cbed192cfb0756b91a6
3
+ metadata.gz: 396d094c919ae767cf6653747b219b0018a95c0672fd8beb9da5c1f0c64fd7c6
4
+ data.tar.gz: fdca15a751308a1c2a6bcf818f21572b7cb1a8e95a8f59c8f363d5431758375a
5
5
  SHA512:
6
- metadata.gz: 73f3c5177366551d7101dd0873e17c6f13dd76b5fb682c0b6b55f07514c9329c728f4e1c5f83c136c7875f5b59968278ad86707010a8b5874b5f4ffdcc386071
7
- data.tar.gz: 43ac9dcdc2d90c3db00e781277abdd544a748cab17a2548de57a6d206d1605302cf93e7a9ab90ddb390f90a2bd8878d92663fd363c99017f4bbe3bc4444f90c8
6
+ metadata.gz: 9e548a9a7493741c606bfdb93f6bbe90a082496e76b739645d658e91b531671170053fb1342272d76e5116093184d548aef593c11cbb1e715227427be295d637
7
+ data.tar.gz: e945766a4d0157bc22ce976a4552fd72b62c2ffc5a153c1e1c44fd9dc5996c88f729bc2eba49b6fbc90d6f6472aaf6e46fedc7c52db687aed8d2aa433bc20708
@@ -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.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OrestF
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-19 00:00:00.000000000 Z
11
+ date: 2023-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  requirements: []
148
- rubygems_version: 3.4.6
148
+ rubygems_version: 3.4.21
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Passpartu makes policies great again