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: ea29ec666170f123b6e3ff8a9e408a47283f3f69
4
- data.tar.gz: 959fb6bbba7b827b9090fe9536ed5f8aff7f38b6
3
+ metadata.gz: 8c7666d72eeab57ad32afdf221266593f63f0c83
4
+ data.tar.gz: 18a72576f1ee8e5273ec3bec971af931d9480733
5
5
  SHA512:
6
- metadata.gz: 42d1405280d706980f7922d05844dde1ee83c755083a58688ad59100a16963ea0b25b24bf9812e1f1290ed575ee227abf53553606fdb820400086f9a072bd480
7
- data.tar.gz: 428228b087dce180039c7a994a56b6a83dcd2c6a7e1578c640e9a347a62b8a147868f3f913ed6562f4b0f1b4c5c9312b755cbc6d117b21ce5e1010f576c55888
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
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Authorization
3
- VERSION = '1.1'.freeze
3
+ VERSION = '1.2'.freeze
4
4
  end
5
5
  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.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-07-20 00:00:00.000000000 Z
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.