Class: Projects::GroupLinks::UpdateService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/projects/group_links/update_service.rb

Constant Summary

Constants inherited from BaseService

BaseService::UnauthorizedError

Instance Attribute Summary

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?, #can_all?, #can_any?

Constructor Details

#initialize(group_link, user = nil) ⇒ UpdateService

Returns a new instance of UpdateService.



6
7
8
9
10
# File 'app/services/projects/group_links/update_service.rb', line 6

def initialize(group_link, user = nil)
  super(group_link.project, user)

  @group_link = group_link
end

Instance Method Details

#execute(group_link_params) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/projects/group_links/update_service.rb', line 12

def execute(group_link_params)
  allowed_params = filter_params(group_link_params)

  if group_link.blank? || !allowed_to_update?
    return ServiceResponse.error(message: 'Not found', reason: :not_found)
  end

  group_link.update!(allowed_params)

  refresh_authorizations if requires_authorization_refresh?(allowed_params)

  ServiceResponse.success
end