Class: WebHooks::DestroyService
- Inherits:
-
Object
- Object
- WebHooks::DestroyService
- Includes:
- Services::ReturnServiceResponses
- Defined in:
- app/services/web_hooks/destroy_service.rb
Overview
Destroy a hook, and schedule the logs for deletion.
Direct Known Subclasses
Constant Summary collapse
- DENIED =
'Insufficient permissions'
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
Instance Method Summary collapse
- #execute(web_hook) ⇒ Object
-
#initialize(current_user) ⇒ DestroyService
constructor
A new instance of DestroyService.
Methods included from Services::ReturnServiceResponses
Constructor Details
#initialize(current_user) ⇒ DestroyService
Returns a new instance of DestroyService.
12 13 14 |
# File 'app/services/web_hooks/destroy_service.rb', line 12 def initialize(current_user) @current_user = current_user end |
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
8 9 10 |
# File 'app/services/web_hooks/destroy_service.rb', line 8 def current_user @current_user end |
Instance Method Details
#execute(web_hook) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/web_hooks/destroy_service.rb', line 16 def execute(web_hook) return error(DENIED, 401) unless (web_hook) hook_id = web_hook.id if web_hook.destroy WebHooks::LogDestroyWorker.perform_async({ 'hook_id' => hook_id }) Gitlab::AppLogger.info((web_hook)) success({ async: false }) else error("Unable to destroy #{web_hook.model_name.human}", 500) end end |