Class: WikiPages::UpdateService

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

Instance Attribute Summary

Attributes inherited from BaseContainerService

#container, #current_user, #params

Instance Method Summary collapse

Methods inherited from BaseContainerService

#initialize

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

This class inherits a constructor from BaseContainerService

Instance Method Details

#event_actionObject


28
29
30
# File 'app/services/wiki_pages/update_service.rb', line 28

def event_action
  :updated
end

#execute(page) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/services/wiki_pages/update_service.rb', line 5

def execute(page)
  # this class is not thread safe!
  @old_slug = page.slug

  if page.update(@params)
    execute_hooks(page)
    ServiceResponse.success(payload: { page: page })
  else
    ServiceResponse.error(
      message: _('Could not update wiki page'),
      payload: { page: page }
    )
  end
end

#external_actionObject


24
25
26
# File 'app/services/wiki_pages/update_service.rb', line 24

def external_action
  'update'
end

#slug_for_page(page) ⇒ Object


32
33
34
# File 'app/services/wiki_pages/update_service.rb', line 32

def slug_for_page(page)
  @old_slug.presence || super
end

#usage_counter_actionObject


20
21
22
# File 'app/services/wiki_pages/update_service.rb', line 20

def usage_counter_action
  :update
end