Class: Decidim::Comments::Abilities::ProcessAdminUser

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

Overview

Defines the abilities related to comments for a logged in process admin user. Intended to be used with ‘cancancan`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, context) ⇒ ProcessAdminUser

Returns a new instance of ProcessAdminUser.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/decidim/comments/abilities/process_admin_user.rb', line 13

def initialize(user, context)
  return unless user && !user.role?(:admin)

  @user = user
  @context = context

  can :manage, Comment do |comment|
    participatory_processes.include?(comment.feature.participatory_process)
  end
  can :unreport, Comment
  can :hide, Comment
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



11
12
13
# File 'app/models/decidim/comments/abilities/process_admin_user.rb', line 11

def context
  @context
end

#userObject (readonly)

Returns the value of attribute user.



11
12
13
# File 'app/models/decidim/comments/abilities/process_admin_user.rb', line 11

def user
  @user
end