unidom-authorization 1.4.4 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2435a1acf8dbeffb9852fab44ba2ddeecb970a4a
4
- data.tar.gz: 128a9d021436050d539cace00f056707d9c5f857
3
+ metadata.gz: 0452e5f8f9c8d59d999f1d6ec3b3a3fd336d0077
4
+ data.tar.gz: 28558f7b515d8028f6e7e68735a740d65d2856fa
5
5
  SHA512:
6
- metadata.gz: ab7a3e2e2df52ea095dbacce94bfd77d8a229d1bacc5580b7a0117adf8a01c134a0cf65d8e486e0592436385033f4bedbd1f93c1027d93a37bda94baaf09c99c
7
- data.tar.gz: b5d9f1611b7d7902ebb998a619b56aad071fecaabb6850a9b4cf12f0467406ca158bda35acb07b4858141c436612924bd641cfb822e2fa673589837f591c0b53
6
+ metadata.gz: c5c900343d6233b7f173ac002b677aaf036474a6bf15e618249f1c09a6663949b2c99d881210ec3c0ad2e1a03b9bbed7a2df3e53a1d10f0e9c72cd29dec93460
7
+ data.tar.gz: 932228df055c759573f05607146c2c890f5f0c41b9fc933cd3cd27dfb5e7b8c800765f2ef0fc943415c5eb865cc5831b2d30cfd984a0af9a6d2309b25b669e9f
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Unidom Authorization 授权领域模型引擎
2
2
 
3
+ [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/unidom-authorization/frames)
3
4
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
5
+
4
6
  [![Gem Version](https://badge.fury.io/rb/unidom-authorization.svg)](https://badge.fury.io/rb/unidom-authorization)
5
7
  [![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-authorization.svg)](https://gemnasium.com/github.com/topbitdu/unidom-authorization)
6
8
 
@@ -62,15 +64,36 @@ include Unidom::Authorization::Concerns::AsPermission
62
64
 
63
65
  ### As Authorized concern
64
66
 
65
- The As Authorized concern do the following tasks for the includer automatically:
66
- 1. Define the has_many :authorizings macro as: ``has_many :authorizings, class_name: 'Unidom::Authorization::Authorizing', as: :authorized``
67
- 2. Define the has_many :permissions macro as: ``has_many :permissions, through: :authorizings, source: :permission``
68
- 3. Define the #is_authorized! method as: ``is_authorized!(permission: nil, by: nil, at: Time.now)``
67
+ The As Authorized concern do the following tasks for the includer automatically:
68
+ 1. Define the has_many :authorizings macro as: ``has_many :authorizings, class_name: 'Unidom::Authorization::Authorizing', as: :authorized``
69
+
70
+ 2. Define the has_many :permissions macro as: ``has_many :permissions, through: :authorizings, source: :permission``
71
+
72
+ 3. Define the #is_authorized! method as: ``is_authorized!(permission: nil, by: nil, at: Time.now)``
73
+
69
74
  4. Define the #is_authorized? method as: ``is_authorized?(permission: nil, at: Time.now)``
70
75
 
71
76
  ### As Permission concern
72
77
 
73
- The As Permission concern do the following tasks for the includer automatically:
74
- 1. Define the has_many :authorizings macro as: ``has_many :authorizings, class_name: 'Unidom::Authorization::Authorizing'``
75
- 2. Define the #authorize! method as: ``authorize!(authorized, by: nil, at: Time.now)``
78
+ The As Permission concern do the following tasks for the includer automatically:
79
+ 1. Define the has_many :authorizings macro as: ``has_many :authorizings, class_name: 'Unidom::Authorization::Authorizing'``
80
+
81
+ 2. Define the #authorize! method as: ``authorize!(authorized, by: nil, at: Time.now)``
82
+
76
83
  3. Define the #authorize? method as: ``authorize?(authorized, at: Time.now)``
84
+
85
+
86
+
87
+ ## Disable the Model & Migration
88
+
89
+ If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.
90
+ ```ruby
91
+ # config/initializers/unidom.rb
92
+ Unidom::Common.configure do |options|
93
+
94
+ options[:neglected_namespaces] = %w{
95
+ Unidom::Authorization
96
+ }
97
+
98
+ end
99
+ ```
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application controller 是模块内所有控制器的基类。
3
+
1
4
  class Unidom::Authorization::ApplicationController < ActionController::Base
2
5
  protect_from_forgery with: :exception
3
6
  end
@@ -1,2 +1,5 @@
1
+ ##
2
+ # Application job 是模块内所有异步任务的基类。
3
+
1
4
  class Unidom::Authorization::ApplicationJob < ActiveJob::Base
2
5
  end
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application mailer 是模块内所有电子邮件发送类的基类。
3
+
1
4
  class Unidom::Authorization::ApplicationMailer < ActionMailer::Base
2
5
  default from: 'from@example.com'
3
6
  layout 'mailer'
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application record 是模块内所有模型的抽象基类。
3
+
1
4
  class Unidom::Authorization::ApplicationRecord < ActiveRecord::Base
2
5
  self.abstract_class = true
3
6
  end
@@ -15,6 +15,10 @@ class Unidom::Authorization::Authorizing < Unidom::Authorization::ApplicationRec
15
15
  scope :authorized_is, ->(authorized) { where authorized: authorized }
16
16
  scope :authorized_by, ->(authorizer) { where authorizer: authorizer }
17
17
 
18
+ ##
19
+ # 授予 authorized 权限 permission ,授权者是 authorizer ,授权时间是 opened_at。如:
20
+ # Unidom::Authorization::Authorizing.authorize! permission: permission,
21
+ # authorized: selected_person, authorizer: current_person
18
22
  def self.authorize!(permission: nil, authorized: nil, authorizer: nil, opened_at: Time.now)
19
23
 
20
24
  assert_present! :permission, permission
@@ -33,4 +37,4 @@ class Unidom::Authorization::Authorizing < Unidom::Authorization::ApplicationRec
33
37
 
34
38
  end
35
39
 
36
- end
40
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Authorization::Authorizing'
@@ -1,3 +1,6 @@
1
+ ##
2
+ # As Authorized 是被授权的参与者或访问者的领域逻辑关注点。
3
+
1
4
  module Unidom::Authorization::Concerns::AsAuthorized
2
5
 
3
6
  extend ActiveSupport::Concern
@@ -7,6 +10,10 @@ module Unidom::Authorization::Concerns::AsAuthorized
7
10
  has_many :authorizings, class_name: 'Unidom::Authorization::Authorizing', as: :authorized
8
11
  has_many :permissions, through: :authorizings, source: :permission
9
12
 
13
+ ##
14
+ # 将本参与者或访问者,授予指定的权限 permission , by 是授权者, at 是授权时间,缺省为当前时间。如:
15
+ # 假设 selected_person 对应的类已经 include Unidom::Authorization::Concerns::AsAuthorized 。
16
+ # selected_person.is_authorized! permission, by: current_person
10
17
  def is_authorized!(permission: nil, by: nil, at: Time.now)
11
18
 
12
19
  assert_present! :permission, permission
@@ -1,3 +1,6 @@
1
+ ##
2
+ # As Permission 是权限的领域逻辑关注点。
3
+
1
4
  module Unidom::Authorization::Concerns::AsPermission
2
5
 
3
6
  extend ActiveSupport::Concern
@@ -6,6 +9,9 @@ module Unidom::Authorization::Concerns::AsPermission
6
9
 
7
10
  has_many :authorizings, class_name: 'Unidom::Authorization::Authorizing'
8
11
 
12
+ ##
13
+ # 将本权限授予指定的参与者或访问者 authorized , by 是授权者, at 是授权时间,缺省为当前时间。如:
14
+ # permission.authorize! selected_person, by: current_person
9
15
  def authorize!(authorized, by: nil, at: Time.now)
10
16
 
11
17
  assert_present! :authorized, authorized
@@ -13,4 +13,4 @@ class Unidom::Authorization::Permission < Unidom::Authorization::ApplicationReco
13
13
 
14
14
  scope :path_is, ->(path) { where path: path }
15
15
 
16
- end
16
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Authorization::Permission'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Authorization
3
- VERSION = '1.4.4'.freeze
3
+ VERSION = '1.4.5'.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.4.4
4
+ version: 1.4.5
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-03 00:00:00.000000000 Z
11
+ date: 2017-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '1.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
- version: '1.8'
26
+ version: '1.9'
27
27
  description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
28
28
  The Authorization domain model engine includes the Permission and Authorizing models.
29
29
  Unidom (统一领域对象模型)是一系列的领域模型引擎。授权领域模型引擎包括权限、授权的模型。