Class: IssuableLinks::DestroyService

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

Instance Attribute Summary collapse

Attributes inherited from BaseService

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

Returns a new instance of DestroyService.



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

def initialize(link, user)
  @link = link
  @current_user = user
  @source = link.source
  @target = link.target
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



5
6
7
# File 'app/services/issuable_links/destroy_service.rb', line 5

def current_user
  @current_user
end

Returns the value of attribute link.



5
6
7
# File 'app/services/issuable_links/destroy_service.rb', line 5

def link
  @link
end

#sourceObject (readonly)

Returns the value of attribute source.



5
6
7
# File 'app/services/issuable_links/destroy_service.rb', line 5

def source
  @source
end

#targetObject (readonly)

Returns the value of attribute target.



5
6
7
# File 'app/services/issuable_links/destroy_service.rb', line 5

def target
  @target
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
# 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
  after_destroy

  success(message: 'Relation was removed')
end