Class: Groups::CreateService

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

Instance Attribute Summary

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?, #can_all?, #can_any?

Constructor Details

#initialize(user, params = {}) ⇒ CreateService

Returns a new instance of CreateService.



5
6
7
8
9
# File 'app/services/groups/create_service.rb', line 5

def initialize(user, params = {})
  @current_user = user
  @params = params.dup
  @chat_team = @params.delete(:create_chat_team)
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/groups/create_service.rb', line 11

def execute
  build_group
  after_build_hook

  return error_response unless valid?

  @group.name ||= @group.path.dup

  create_chat_team
  create_group

  return error_response unless @group.persisted?

  after_successful_creation_hook

  ServiceResponse.success(payload: { group: @group })
end