module Authorule::PermissionHolder
Makes any ActiveModel/ActiveRecord-like class a UI permission holder.
Usage¶ ↑
class User include Authorule::PermissionHolder is_permission_holder! end
-
A (has many)
permission_rules
association is added to the model (though the name may be changed in the {.is_permission_holder!} method). -
A {#may?} and {#may_not?} method is added.
Public Instance Methods
has_permission?(permission)
click to toggle source
Determines whether this holder has the given permission by running it through his rule base.
# File lib/authorule/permission_holder.rb, line 45 def has_permission?(permission) unless respond_to?(:permission_rule_base) raise "class not set up as permission holder, call is_permission_holder! first" end permission_rule_base.run permission end