app/models/unidom/authorization/concerns/as_authorized.rb in unidom-authorization-1.6.8 vs app/models/unidom/authorization/concerns/as_authorized.rb in unidom-authorization-1.6.9
- old
+ new
@@ -12,19 +12,27 @@
##
# 将本参与者或访问者,授予指定的权限 permission , by 是授权者, at 是授权时间,缺省为当前时间。如:
# 假设 selected_person 对应的类已经 include Unidom::Authorization::Concerns::AsAuthorized 。
# selected_person.is_authorized! permission, by: current_person
+ # # or
+ # selected_person.is_authorized! permission, by: current_person, at: Time.now
def is_authorized!(permission: nil, by: nil, at: Time.now)
assert_present! :permission, permission
assert_present! :by, by
assert_present! :at, at
authorizings.create! permission: permission, authorizer: by, opened_at: at
end
+ ##
+ # 判断本参与者或访问者,在给定的时间 at 是否拥有给定的权限 permission 。如:
+ # 假设 selected_person 对应的类已经 include Unidom::Authorization::Concerns::AsAuthorized 。
+ # selected_person.is_authorized? permission
+ # # or
+ # selected_person.is_authorized? permission, at: Time.now
def is_authorized?(permission: nil, at: Time.now)
assert_present! :permission, permission
assert_present! :at, at