Class: IssuableLinks::DestroyService

Inherits:
BaseService show all
Includes:
IncidentManagement::UsageData
Defined in:
app/services/issuable_links/destroy_service.rb

Direct Known Subclasses

IssueLinks::DestroyService

Constant Summary

Constants included from Gitlab::Utils::UsageData

Gitlab::Utils::UsageData::FALLBACK

Instance Attribute Summary collapse

Attributes inherited from BaseService

#params, #project

Instance Method Summary collapse

Methods included from IncidentManagement::UsageData

#track_event, #track_incident_action

Methods included from Gitlab::Utils::UsageData

#alt_usage_data, #count, #distinct_count, #measure_duration, #redis_usage_data, #track_usage_event, #with_finished_at, #with_prometheus_client

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(link, user) ⇒ DestroyService

Returns a new instance of DestroyService.


9
10
11
12
# File 'app/services/issuable_links/destroy_service.rb', line 9

def initialize(link, user)
  @link = link
  @current_user = user
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user


7
8
9
# File 'app/services/issuable_links/destroy_service.rb', line 7

def current_user
  @current_user
end

Returns the value of attribute link


7
8
9
# File 'app/services/issuable_links/destroy_service.rb', line 7

def link
  @link
end

Instance Method Details

#executeObject


14
15
16
17
18
19
20
21
22
# File 'app/services/issuable_links/destroy_service.rb', line 14

def execute
  return error(not_found_message, 404) unless permission_to_remove_relation?

  remove_relation
  create_notes
  track_event

  success(message: 'Relation was removed')
end