module Rbac::Resource
Defined in:
rbac/resource.crInstance Method Summary
-
#authorized?(roleable : Roleable)
check if a Roleable has any of the roles that the resource has ``` s = Store.new # includes Resource s.has_roles :add, :delete
-
#authorized?(roleable : Roleable, *_roles : Symbol)
check if a Roleable has a specific role that the resource has ``` s = Store.new # includes Resource s.has_roles :add, :delete
-
#has_role?(role : Symbol)
check if a resource has a specific role
s = Store.new # includes Resource s.has_roles :add, :delete s.has_role? :add # => true
-
#has_roles(roles : Array(Symbol))
add allowed roles
s = Store.new # includes Resource s.has_roles [:add, :delete]
-
#has_roles(*_roles : Symbol)
add allowed roles
s = Store.new # includes Resource s.has_roles :add, :delete
-
#may?(roleable : Roleable, *_roles : Symbol)
alias to
#authorized?(Roleable, *Symbol)
- #roles
Instance Method Detail
check if a Roleable has any of the roles that the resource has
s = Store.new # includes Resource
s.has_roles :add, :delete
u = User.new # includes Roleable
u.has_roles :add, :edit
s.authorized?(u) # => true because of :add
check if a Roleable has a specific role that the resource has
s = Store.new # includes Resource
s.has_roles :add, :delete
u = User.new # includes Roleable
u.has_roles :add, :edit
s.authorized?(u, :add) # => true
s.authorized?(u, :delete) # => false
s.authorized?(u, :edit) # => false because store does not include :edit role
# check multiple rows at once:
s.authorized?(u, :add, :delete) # => false
check if a resource has a specific role
s = Store.new # includes Resource
s.has_roles :add, :delete
s.has_role? :add # => true
add allowed roles
s = Store.new # includes Resource
s.has_roles [:add, :delete]
add allowed roles
s = Store.new # includes Resource
s.has_roles :add, :delete