Class: Users::UpdateHighestMemberRoleService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/users/update_highest_member_role_service.rb

Instance Attribute Summary collapse

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(user) ⇒ UpdateHighestMemberRoleService

Returns a new instance of UpdateHighestMemberRoleService.


7
8
9
# File 'app/services/users/update_highest_member_role_service.rb', line 7

def initialize(user)
  @user = user
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.


5
6
7
# File 'app/services/users/update_highest_member_role_service.rb', line 5

def user
  @user
end

Instance Method Details

#executeObject


11
12
13
14
15
# File 'app/services/users/update_highest_member_role_service.rb', line 11

def execute
  return true if user_highest_role.persisted? && highest_access_level == user_highest_role.highest_access_level

  user_highest_role.update!(highest_access_level: highest_access_level)
end