credential_authorization 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed3869fa7e81dde4e217229ae7c47e7faea3132c093eaae300d58a28adf8c656
4
- data.tar.gz: 80f75ccce9922cdd8c07d3cb0cca11b1435d3b69661ee4df5d14cf3b0d07bdd6
3
+ metadata.gz: db045c130d449eb4a7a483313b39d085f3a56f9d274a2a7a7a18c4f92bacd516
4
+ data.tar.gz: 89a302c955acf1abfb4edb4f225574f5eb8fbadde36dae79dd90b3b585e13fbf
5
5
  SHA512:
6
- metadata.gz: bccf752f971f2b7baa3b7eb4963a7ccac2aea9314a4545806394c72148f13735fe9d93cc21225e0d6391cd60d0a7050a5fc157df1a491679233afe382a7d954b
7
- data.tar.gz: 1db2501a8f9fb350fd10934f01e48c932c8a19b628026cb17abf28e2f8cdd1733932ea6507a9be45c36e1cf0088743b02b42958a7d920d163daf45044b6ae752
6
+ metadata.gz: 8864fc536fde23d3ce1ac8af5dfdd8fcec220dd104b5ade58917de6f4a102e4eb8b295fa52b6c42d65e96c6b80b2d2cc3ce5b10e92bbdf822f4c99cd913db08e
7
+ data.tar.gz: cc39097a084defc0a21f875d2b87753caebff90deb798fde426b82546d679b53a2482d83545d31a2269ec49cd0208001e99aa9e0dee1e2601ab979659dacd9cd
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CredentialAuthorization
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
@@ -12,31 +12,31 @@ module CredentialAuthorization
12
12
  yield self
13
13
  end
14
14
 
15
- def self.can?(permission)
16
- found = self.find_permission(permission)
15
+ def self.can?(record:, permission:)
16
+ found = self.find_permission(self.build_permission_key(record:, permission:))
17
17
 
18
18
  yield if block_given? && found
19
19
  found
20
20
  end
21
21
 
22
- def self.can!(permission, &block)
23
- raise CredentialAuthorization::InsufficientPermission.new(permission) unless self.can?(permission, &block)
22
+ def self.can!(record:, permission:, &block)
23
+ raise CredentialAuthorization::InsufficientPermission.new(permission) unless self.can?(record:, permission:, &block)
24
24
  true
25
25
  end
26
26
 
27
- def self.cannot?(permission)
28
- found = self.find_permission(permission)
27
+ def self.cannot?(record:, permission:)
28
+ found = self.find_permission(self.build_permission_key(record:, permission:))
29
29
 
30
30
  yield if block_given? && !found
31
31
  !found
32
32
  end
33
33
 
34
- def self.cannot!(permission, &block)
35
- raise CredentialAuthorization::SufficientPermission.new(permission) unless self.cannot?(permission, &block)
34
+ def self.cannot!(record:, permission:, &block)
35
+ raise CredentialAuthorization::SufficientPermission.new(permission) unless self.cannot?(record:, permission:, &block)
36
36
  true
37
37
  end
38
38
 
39
- def build_permission_key(record:, permission:)
39
+ def self.build_permission_key(record:, permission:)
40
40
  "#{record.class.name.downcase}.#{record.id}.#{permission}"
41
41
  end
42
42
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: credential_authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - JoelGamer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-01 00:00:00.000000000 Z
11
+ date: 2024-10-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: