app/models/unidom/authorization/concerns/as_permission.rb in unidom-authorization-1.6.5 vs app/models/unidom/authorization/concerns/as_permission.rb in unidom-authorization-1.6.6

- old
+ new

@@ -1,11 +1,12 @@ ## # As Permission 是权限的领域逻辑关注点。 module Unidom::Authorization::Concerns::AsPermission - extend ActiveSupport::Concern + extend ActiveSupport::Concern + include Unidom::Common::Concerns::ArgumentValidation included do |includer| has_many :authorizings, class_name: 'Unidom::Authorization::Authorizing' @@ -13,18 +14,19 @@ # 将本权限授予指定的参与者或访问者 authorized , by 是授权者, at 是授权时间,缺省为当前时间。如: # permission.authorize! selected_person, by: current_person def authorize!(authorized, by: nil, at: Time.now) assert_present! :authorized, authorized + assert_present! :by, by assert_present! :at, at - attributes = { authorized: authorized, opened_at: at } - if by.present? - attributes[:authorizer] = by - else - attributes[:authorizer_id] = Unidom::Common::NULL_UUID - attributes[:authorizer_type] = '' - end + attributes = { authorized: authorized, authorizer: by, opened_at: at } + #if by.present? + # attributes[:authorizer] = by + #else + # attributes[:authorizer_id] = Unidom::Common::NULL_UUID + # attributes[:authorizer_type] = '' + #end authorizings.create! attributes end def authorize?(authorized, at: Time.now)