Class: WebHooks::DestroyService

Inherits:
Object
  • Object
show all
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

AdminDestroyService

Constant Summary collapse

DENIED =
'Insufficient permissions'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Services::ReturnServiceResponses

#error, #success

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_userObject

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 authorized?(web_hook)

  if web_hook.destroy
    after_destroy(web_hook)
  else
    error("Unable to destroy #{web_hook.model_name.human}", 500)
  end
end