Class: WebHooks::AdminDestroyService

Inherits:
DestroyService show all
Defined in:
app/services/web_hooks/admin_destroy_service.rb

Overview

A variant of the destroy service that can only be used by an administrator from a rake task.

Constant Summary

Constants inherited from DestroyService

DestroyService::DENIED

Instance Attribute Summary

Attributes inherited from DestroyService

#current_user

Instance Method Summary collapse

Methods inherited from DestroyService

#execute

Methods included from Services::ReturnServiceResponses

#error, #success

Constructor Details

#initialize(rake_task:) ⇒ AdminDestroyService

Returns a new instance of AdminDestroyService.



7
8
9
10
# File 'app/services/web_hooks/admin_destroy_service.rb', line 7

def initialize(rake_task:)
  super(nil)
  @rake_task = rake_task
end

Instance Method Details

#authorized?(web_hook) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/services/web_hooks/admin_destroy_service.rb', line 12

def authorized?(web_hook)
  @rake_task.present? # Not impossible to circumvent, but you need to provide something
end

#log_message(hook) ⇒ Object



16
17
18
# File 'app/services/web_hooks/admin_destroy_service.rb', line 16

def log_message(hook)
  "An administrator scheduled a deletion of logs for hook ID #{hook.id} from #{@rake_task.name}"
end