Class: Namespaces::RestoreBaseService

Inherits:
BaseService show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/namespaces/restore_base_service.rb

Constant Summary collapse

DELETED_SUFFIX_REGEX =
/
  -
  (#{MarkForDeletionBaseService::LEGACY_DELETION_SCHEDULED_PATH_INFIX}
    |#{MarkForDeletionBaseService::DELETION_SCHEDULED_PATH_INFIX})
  -
  \d+\z
/x

Constants inherited from BaseService

BaseService::UnauthorizedError

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

#initialize(resource, user, params = {}) ⇒ RestoreBaseService

Returns a new instance of RestoreBaseService.



15
16
17
18
19
# File 'app/services/namespaces/restore_base_service.rb', line 15

def initialize(resource, user, params = {})
  @resource = resource
  @current_user = user
  @params = params.dup
end

Instance Method Details

#executeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/services/namespaces/restore_base_service.rb', line 21

def execute
  result = preconditions_checks
  return result if result.error?

  result = execute_restore

  if result.success?
    log_event
    post_success
  end

  result
end