Module: Authorule::PermissionAccessors
- Included in:
- PermissionHolder
- Defined in:
- lib/authorule/permission_accessors.rb
Overview
Provides methods ‘may?’, ‘may_access?’ and their negative counterparts. You must make sure to implement method ‘has_permission?’ in your class.
Instance Method Summary collapse
-
#may?(action, target) ⇒ Boolean
Determines whether a holder in this group may perform the specified action on the specified target.
-
#may_access?(target) ⇒ Boolean
Checks a permission without querying a specific action.
-
#may_not?(action, target) ⇒ Boolean
Determines whether a holder may not perform the specified action on the specified target.
-
#may_not_access?(target) ⇒ Boolean
Determines whether a holder may not access the specified target.
Instance Method Details
#may?(action, target) ⇒ Boolean
Determines whether a holder in this group may perform the specified action on the specified target.
15 16 17 18 19 20 21 22 |
# File 'lib/authorule/permission_accessors.rb', line 15 def may?(action, target) = Authorule.resolve(target, action) unless .available_actions.try(:include?, action) raise ArgumentError, "action :#{action} not available for permission of kind :#{.class.kind}" end end |
#may_access?(target) ⇒ Boolean
Checks a permission without querying a specific action.
26 27 28 29 |
# File 'lib/authorule/permission_accessors.rb', line 26 def may_access?(target) = Authorule.resolve(target) end |
#may_not?(action, target) ⇒ Boolean
Determines whether a holder may not perform the specified action on the specified target.
33 34 35 |
# File 'lib/authorule/permission_accessors.rb', line 33 def may_not?(action, target) !may?(action, target) end |
#may_not_access?(target) ⇒ Boolean
Determines whether a holder may not access the specified target.
40 41 42 |
# File 'lib/authorule/permission_accessors.rb', line 40 def may_not_access?(target) !may_access?(target) end |