Class: Alchemy::Permissions
- Inherits:
-
Object
- Object
- Alchemy::Permissions
- Includes:
- AdminUser, AuthorUser, EditorUser, GuestUser, MemberUser, CanCan::Ability
- Defined in:
- lib/alchemy/permissions.rb
Overview
## Alchemy’s permissions
These are CanCan abilities, but to prevent any naming collusions we named it permissions.
Alchemy user rules are modules that can be included in your app’s/engine’s Ability class.
### Example:
# app/models/ability.rb
class Ability
include CanCan::Ability
include Alchemy::Permissions::EditorUser
def initialize(user)
return if user.nil?
@user ||= user
if @user.has_role?(:demo)
alchemy_editor_rules # alchemy editor roles
# your own rules
end
end
end
Defined Under Namespace
Modules: AdminUser, AuthorUser, EditorUser, GuestUser, MemberUser
Instance Method Summary collapse
-
#initialize(user) ⇒ Permissions
constructor
A new instance of Permissions.
Methods included from AdminUser
Methods included from EditorUser
Methods included from AuthorUser
Methods included from MemberUser
Methods included from GuestUser
Constructor Details
#initialize(user) ⇒ Permissions
Returns a new instance of Permissions.
28 29 30 31 32 |
# File 'lib/alchemy/permissions.rb', line 28 def initialize(user) set_action_aliases @user ||= user @user ? user_role_rules : alchemy_guest_user_rules end |