Class: Unidom::Authorization::Permission
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Unidom::Authorization::Permission
- Includes:
- Common::Concerns::ModelExtension
- Defined in:
- app/models/unidom/authorization/permission.rb
Overview
Permission 是权限。
Instance Method Summary collapse
- #authorize!(authorized, by: nil, at: Time.now) ⇒ Object
- #authorized?(authorized, at: Time.now) ⇒ Boolean
Instance Method Details
#authorize!(authorized, by: nil, at: Time.now) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/unidom/authorization/permission.rb', line 16 def (, by: nil, at: Time.now) attributes = { authorized: , opened_at: at } if by.present? attributes[:authorizer] = by else attributes[:authorizer_id] = Unidom::Common::NULL_UUID attributes[:authorizer_type] = '' end .create! attributes end |
#authorized?(authorized, at: Time.now) ⇒ Boolean
27 28 29 |
# File 'app/models/unidom/authorization/permission.rb', line 27 def (, at: Time.now) .().valid_at(now: at).alive.exists? end |