unidom-authorization 1.5 → 1.6

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: cf149681710bff4f470a6f3d25b18767038a4772
4
- data.tar.gz: f1524067ef71b2a90635673674206d446bf966a6
3
+ metadata.gz: aa88ea09708ff93a8e36dccea63e8443ad8dd9a0
4
+ data.tar.gz: 544cccc83c3f7d4b3faacdfd248d9863464b4490
5
5
  SHA512:
6
- metadata.gz: 2fdadafbb33ed70678f478cca1e39241f2052be9877fb5b7945431d97d210d0ca7084d39208616c178ed8ec0985c691be62e24622bb507b1f0dae9075eedf0d2
7
- data.tar.gz: f175c979d6640c9bc1bb1e243f6a805244a7b5d5f0bd9b2a1ef06a63609e0a312745b5c4da55f54ecee7b8f6e2d5ba575c80e7aad0246ec5fad92659398355f6
6
+ metadata.gz: 2c8973978d955828416f21e2db425843503d904177fa5d6d61821a1cebf365f40f0ff2611a245a18aeef52f6fb3cbb897574e7b59fd4ed5c240006cba897ee7a
7
+ data.tar.gz: d25f9fdc913dfeebf11b4f552d791c1e2d3bcac20077da612f48364f19995aec26a3bcbc8f58572cdce099f444715bff0f512744aa699ac3371737b6a691c261
data/README.md CHANGED
@@ -45,12 +45,17 @@ permission = Unidom::Authorization::Permission.valid_at.alive.first
45
45
 
46
46
  permission.authorized? user, at: Time.now # false
47
47
  Unidom::Authorization::Authorizing.authorize! permission: permission, authorized: user
48
- # or
49
- permission.authorize! user, by: current_user, at: Time.now
50
- permission.authorize? user, at: Time.now # true
48
+ # or: permission.authorize! user, by: current_user, at: Time.now
49
+ # or: user.is_authorized! permission: permission, by: administrator, at: Time.now
51
50
 
52
- user.is_authorized! permission: permission, by: administrator, at: Time.now
51
+ permission.authorize? user, at: Time.now # true
53
52
  user.is_authorized? permission: permission, at: Time.now # true
53
+
54
+ user.is_prohibted! permission: permission, at: Time.now
55
+ # or: permission.prohibit! user, at: Time.now
56
+
57
+ permission.authorize? user, at: Time.now # false
58
+ user.is_authorized? permission: permission, at: Time.now # false
54
59
  ```
55
60
 
56
61
 
@@ -73,6 +78,8 @@ The As Authorized concern do the following tasks for the includer automatically:
73
78
 
74
79
  4. Define the #is_authorized? method as: ``is_authorized?(permission: nil, at: Time.now)``
75
80
 
81
+ 5. Define the #is_prohibited! method as: ``is_prohibited!(permission: nil, at: Time.now)``
82
+
76
83
  ### As Permission concern
77
84
 
78
85
  The As Permission concern do the following tasks for the includer automatically:
@@ -82,6 +89,8 @@ The As Permission concern do the following tasks for the includer automatically:
82
89
 
83
90
  3. Define the #authorize? method as: ``authorize?(authorized, at: Time.now)``
84
91
 
92
+ 4. Define the #prohibit! method as: ``prohibit!(authorized, at: Time.now)``
93
+
85
94
 
86
95
 
87
96
  ## Disable the Model & Migration
@@ -33,6 +33,15 @@ module Unidom::Authorization::Concerns::AsAuthorized
33
33
 
34
34
  end
35
35
 
36
+ def is_prohibited!(permission: nil, at: Time.now)
37
+
38
+ assert_present! :permission, permission
39
+ assert_present! :at, at
40
+
41
+ authorizings.permission_is(permission).valid_at(now: at).alive.update_all closed_at: at, defunct: true
42
+
43
+ end
44
+
36
45
  end
37
46
 
38
47
  module ClassMethods
@@ -44,6 +44,15 @@ module Unidom::Authorization::Concerns::AsPermission
44
44
 
45
45
  end
46
46
 
47
+ def prohibit!(authorized, at: Time.now)
48
+
49
+ assert_present! :authorized, authorized
50
+ assert_present! :at, at
51
+
52
+ authorizings.authorized_is(authorized).valid_at(now: at).alive.update_all closed_at: at, defunct: true
53
+
54
+ end
55
+
47
56
  end
48
57
 
49
58
  module ClassMethods
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Authorization
3
- VERSION = '1.5'.freeze
3
+ VERSION = '1.6'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.5'
4
+ version: '1.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-30 00:00:00.000000000 Z
11
+ date: 2017-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common