app/models/unidom/authorization/authorizing.rb in unidom-authorization-1.4.4 vs app/models/unidom/authorization/authorizing.rb in unidom-authorization-1.4.5
- old
+ new
@@ -13,10 +13,14 @@
scope :permission_is, ->(permission) { where permission_id: (permission.respond_to?(:id) ? permission.id : permission) }
scope :authorized_is, ->(authorized) { where authorized: authorized }
scope :authorized_by, ->(authorizer) { where authorizer: authorizer }
+ ##
+ # 授予 authorized 权限 permission ,授权者是 authorizer ,授权时间是 opened_at。如:
+ # Unidom::Authorization::Authorizing.authorize! permission: permission,
+ # authorized: selected_person, authorizer: current_person
def self.authorize!(permission: nil, authorized: nil, authorizer: nil, opened_at: Time.now)
assert_present! :permission, permission
assert_present! :authorized, authorized
assert_present! :opened_at, opened_at
@@ -31,6 +35,6 @@
self.authorized_is(authorized).permission_is(permission).valid_at.alive.first_or_create! attributes
end
-end
+end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Authorization::Authorizing'