2018-07-18 12:03:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-28 02:26:52 -05:00
|
|
|
module WikiPages
|
|
|
|
class UpdateService < WikiPages::BaseService
|
|
|
|
def execute(page)
|
2020-03-24 08:09:42 -04:00
|
|
|
# this class is not thread safe!
|
|
|
|
@old_slug = page.slug
|
|
|
|
|
2017-07-23 04:19:10 -04:00
|
|
|
if page.update(@params)
|
2020-03-24 08:09:42 -04:00
|
|
|
execute_hooks(page)
|
2016-02-28 02:26:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
page
|
|
|
|
end
|
2020-03-24 08:09:42 -04:00
|
|
|
|
|
|
|
def usage_counter_action
|
|
|
|
:update
|
|
|
|
end
|
|
|
|
|
|
|
|
def external_action
|
|
|
|
'update'
|
|
|
|
end
|
|
|
|
|
|
|
|
def event_action
|
|
|
|
Event::UPDATED
|
|
|
|
end
|
|
|
|
|
|
|
|
def slug_for_page(page)
|
|
|
|
@old_slug.presence || super
|
|
|
|
end
|
2016-02-28 02:26:52 -05:00
|
|
|
end
|
|
|
|
end
|