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 +4 -4
- data/lib/credential_authorization/version.rb +1 -1
- data/lib/credential_authorization.rb +9 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db045c130d449eb4a7a483313b39d085f3a56f9d274a2a7a7a18c4f92bacd516
|
4
|
+
data.tar.gz: 89a302c955acf1abfb4edb4f225574f5eb8fbadde36dae79dd90b3b585e13fbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8864fc536fde23d3ce1ac8af5dfdd8fcec220dd104b5ade58917de6f4a102e4eb8b295fa52b6c42d65e96c6b80b2d2cc3ce5b10e92bbdf822f4c99cd913db08e
|
7
|
+
data.tar.gz: cc39097a084defc0a21f875d2b87753caebff90deb798fde426b82546d679b53a2482d83545d31a2269ec49cd0208001e99aa9e0dee1e2601ab979659dacd9cd
|
@@ -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
|
23
|
-
raise CredentialAuthorization::InsufficientPermission.new(permission) unless self.can?(permission
|
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
|
35
|
-
raise CredentialAuthorization::SufficientPermission.new(permission) unless self.cannot?(permission
|
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.
|
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-
|
11
|
+
date: 2024-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|