Class: Alchemy::Devise::Ability

Inherits:
Object
  • Object
show all
Includes:
CanCan::Ability
Defined in:
lib/alchemy/devise/ability.rb

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Ability

Returns a new instance of Ability.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/alchemy/devise/ability.rb', line 6

def initialize(user)
  @user = user

  can :signup, Alchemy::User
  can :create, Alchemy::User if Alchemy::User.count == 0

  if member? || author? || editor?
    can [:show, :update], Alchemy::User, id: user.id
  end

  if editor? || admin?
    can :index, :alchemy_admin_users
    can :read, Alchemy::User
  end

  if admin?
    can :manage, Alchemy::User
  end
end