debian-mirror-gitlab/app/services/users/update_highest_member_role_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
639 B
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
module Users
class UpdateHighestMemberRoleService < BaseService
attr_reader :user
def initialize(user)
@user = user
end
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
private
def user_highest_role
2023-03-04 22:38:38 +05:30
@user_highest_role ||= @user.user_highest_role || @user.build_user_highest_role
2020-04-22 19:07:51 +05:30
end
def highest_access_level
@highest_access_level ||= @user.current_highest_access_level
end
end
end