Class: Groups::TransferService

Inherits:
BaseService show all
Defined in:
app/services/groups/transfer_service.rb

Constant Summary collapse

TransferError =
Class.new(StandardError)

Instance Attribute Summary collapse

Attributes inherited from BaseService

#current_user, #group, #params

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?

Constructor Details

#initialize(group, user, params = {}) ⇒ TransferService

Returns a new instance of TransferService.


9
10
11
12
# File 'app/services/groups/transfer_service.rb', line 9

def initialize(group, user, params = {})
  super
  @error = nil
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error


7
8
9
# File 'app/services/groups/transfer_service.rb', line 7

def error
  @error
end

#new_parent_groupObject (readonly)

Returns the value of attribute new_parent_group


7
8
9
# File 'app/services/groups/transfer_service.rb', line 7

def new_parent_group
  @new_parent_group
end

Instance Method Details

#execute(new_parent_group) ⇒ Object


14
15
16
17
18
19
20
21
22
23
# File 'app/services/groups/transfer_service.rb', line 14

def execute(new_parent_group)
  @new_parent_group = new_parent_group
  ensure_allowed_transfer
  proceed_to_transfer

rescue TransferError, ActiveRecord::RecordInvalid, Gitlab::UpdatePathError => e
  @group.errors.clear
  @error = s_("TransferGroup|Transfer failed: %{error_message}") % { error_message: e.message }
  false
end