Class: WebHooks::DestroyService
- Inherits:
-
Object
- Object
- WebHooks::DestroyService
- Includes:
- Services::ReturnServiceResponses
- Defined in:
- app/services/web_hooks/destroy_service.rb
Overview
Destroys a WebHook record.
Note: Log cleanup is handled automatically through daily partitioning of the web_hook_logs table, so manual log purging is not required.
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.
15 16 17 |
# File 'app/services/web_hooks/destroy_service.rb', line 15 def initialize(current_user) @current_user = current_user end |
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
11 12 13 |
# File 'app/services/web_hooks/destroy_service.rb', line 11 def current_user @current_user end |
Instance Method Details
#execute(web_hook) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/services/web_hooks/destroy_service.rb', line 19 def execute(web_hook) return error(DENIED, 401) unless (web_hook) if web_hook.destroy after_destroy(web_hook) else error("Unable to destroy #{web_hook.model_name.human}", 500) end end |