unidom-authorization 1.1 → 1.2
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c7666d72eeab57ad32afdf221266593f63f0c83
|
4
|
+
data.tar.gz: 18a72576f1ee8e5273ec3bec971af931d9480733
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28d2f78b4c9a2565d6c023b6974b50b8545b73ae6268c697b9d4703565031385b2dab989cacc356c01d68f5bb8e13d8f6d3f3fcedf20668bc3cb72c401a2f269
|
7
|
+
data.tar.gz: 38ed22a39198bcf3902d4a2dba9000cf3800eea5e406271c86d2d7311cfd0a296deaf32297a2add6f85eb82401ead722cb672fc6e3a11cafc79395e4fa2db0c2
|
data/README.md
CHANGED
@@ -34,6 +34,8 @@ Unidom::Authorization::Authorizing.authorize! permission: permission, authorized
|
|
34
34
|
permission.authorize! user, by: current_user, at: Time.now
|
35
35
|
permission.authorized? user, at: Time.now # true
|
36
36
|
|
37
|
+
user.is_authorized! permission: permission, by: administrator, at: Time.now
|
38
|
+
user.is_authorized? permission: permission, at: Time.now # true
|
37
39
|
```
|
38
40
|
|
39
41
|
## Include the Conerns
|
@@ -42,6 +44,8 @@ include Unidom::Authorization::Concerns::AsAuthorized
|
|
42
44
|
```
|
43
45
|
|
44
46
|
### As Authorized concern
|
45
|
-
The As Authorized concern do the following tasks for the includer automatically:
|
46
|
-
1. Define the has_many :authorizings macro as: ``has_many :authorizings, class_name: 'Unidom::Authorization::Authorizing', as: :authorized``
|
47
|
-
2. Define the has_many :permissions macro as: ``has_many :permissions, through: :authorizings, source: :permission``
|
47
|
+
The As Authorized concern do the following tasks for the includer automatically:
|
48
|
+
1. Define the has_many :authorizings macro as: ``has_many :authorizings, class_name: 'Unidom::Authorization::Authorizing', as: :authorized``
|
49
|
+
2. Define the has_many :permissions macro as: ``has_many :permissions, through: :authorizings, source: :permission``
|
50
|
+
3. Define the #is_authorized! method as: ``def is_authorized!(permission: nil, by: nil, at: Time.now)``
|
51
|
+
4. Define the #is_authorized? method ``def is_authorized?(permission: nil, at: Time.now)``
|
@@ -7,6 +7,14 @@ module Unidom::Authorization::Concerns::AsAuthorized
|
|
7
7
|
has_many :authorizings, class_name: 'Unidom::Authorization::Authorizing', as: :authorized
|
8
8
|
has_many :permissions, through: :authorizings, source: :permission
|
9
9
|
|
10
|
+
def is_authorized!(permission: nil, by: nil, at: Time.now)
|
11
|
+
authorizings.create! permission: permission, authorizer: by, opened_at: at
|
12
|
+
end
|
13
|
+
|
14
|
+
def is_authorized?(permission: nil, at: Time.now)
|
15
|
+
authorizings.permission_is(permission).valid_at(now: at).alive.exists?
|
16
|
+
end
|
17
|
+
|
10
18
|
end
|
11
19
|
|
12
20
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-authorization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.9'
|
27
27
|
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|