Class: WikiPages::DestroyService

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

Instance Attribute Summary

Attributes inherited from BaseContainerService

#container, #current_user, #group, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::InternalEventsTracking

#track_internal_event

Methods inherited from BaseContainerService

#group_container?, #initialize, #namespace_container?, #project_container?, #project_group, #root_ancestor

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

This class inherits a constructor from BaseContainerService

Instance Method Details

#event_actionObject



23
24
25
# File 'app/services/wiki_pages/destroy_service.rb', line 23

def event_action
  :destroyed
end

#execute(page) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'app/services/wiki_pages/destroy_service.rb', line 5

def execute(page)
  if page.delete
    execute_hooks(page)
    ServiceResponse.success(payload: { page: page })
  else
    message = page.template? ? _('Could not delete wiki template') : _('Could not delete wiki page')
    ServiceResponse.error(message: message, payload: { page: page })
  end
end

#external_actionObject



19
20
21
# File 'app/services/wiki_pages/destroy_service.rb', line 19

def external_action
  'delete'
end

#fingerprint(page) ⇒ Object



27
28
29
# File 'app/services/wiki_pages/destroy_service.rb', line 27

def fingerprint(page)
  page.wiki.repository.head_commit.sha
end

#internal_event_nameObject



15
16
17
# File 'app/services/wiki_pages/destroy_service.rb', line 15

def internal_event_name
  'delete_wiki_page'
end