Class: Members::CreatorService

Inherits:
Object
  • Object
show all
Defined in:
app/services/members/creator_service.rb

Overview

This class serves as more of an app-wide way we add/create members All roads to add members should take this path.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, user, access_level, **args) ⇒ CreatorService

Returns a new instance of CreatorService.


17
18
19
20
21
22
# File 'app/services/members/creator_service.rb', line 17

def initialize(source, user, access_level, **args)
  @source = source
  @user = user
  @access_level = self.class.parsed_access_level(access_level)
  @args = args
end

Class Method Details

.access_levelsObject


12
13
14
# File 'app/services/members/creator_service.rb', line 12

def access_levels
  Gitlab::Access.sym_options_with_owner
end

.parsed_access_level(access_level) ⇒ Object


8
9
10
# File 'app/services/members/creator_service.rb', line 8

def parsed_access_level(access_level)
  access_levels.fetch(access_level) { access_level.to_i }
end

Instance Method Details

#executeObject


24
25
26
27
28
29
30
# File 'app/services/members/creator_service.rb', line 24

def execute
  find_or_build_member
  commit_member
  create_member_task

  member
end