Class: Spree::PermissionSets::RoleManagement

Inherits:
PermissionSets::Base
  • Object
show all
Defined in:
app/models/spree/permission_sets/role_management.rb

Instance Method Summary collapse

Instance Method Details

#activate!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/spree/permission_sets/role_management.rb', line 7

def activate!
  can [
    :admin,
    :display,
    :create,
    :update,
    :save_in_address_book,
    :remove_from_address_book,
    :addresses,
    :orders,
    :items
  ],
    Spree.user_class

  # due to how cancancan filters by associations,
  # we have to define this twice, once for `accessible_by`
  can :update_email, Spree.user_class, spree_roles: { id: nil }
  # and once for `can?`
  can :update_email, Spree.user_class do |user|
    user.spree_roles.none?
  end

  cannot [:delete, :destroy], Spree.user_class
  can :manage, Spree::StoreCredit
  can :manage, Spree::Role
end