Class: Decidim::Assemblies::Abilities::AssemblyRoleAbility

Inherits:
Object
  • Object
show all
Includes:
CanCan::Ability
Defined in:
app/models/decidim/assemblies/abilities/assembly_role_ability.rb

Overview

Defines the abilities for any user that can manage assemblies (whatever their role). Intended to be used with ‘cancancan`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, context) ⇒ AssemblyRoleAbility

Returns a new instance of AssemblyRoleAbility.



13
14
15
16
17
18
# File 'app/models/decidim/assemblies/abilities/assembly_role_ability.rb', line 13

def initialize(user, context)
  @user = user
  @context = context

  define_abilities if not_admin? && has_manageable_assemblies?
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



11
12
13
# File 'app/models/decidim/assemblies/abilities/assembly_role_ability.rb', line 11

def user
  @user
end

Instance Method Details

#define_abilitiesObject



20
21
22
23
# File 'app/models/decidim/assemblies/abilities/assembly_role_ability.rb', line 20

def define_abilities
  can :read, :admin_dashboard
  can :read, Assembly
end