Class: DestroyGroupService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group, user) ⇒ DestroyGroupService

Returns a new instance of DestroyGroupService


4
5
6
# File 'app/services/destroy_group_service.rb', line 4

def initialize(group, user)
  @group, @current_user = group, user
end

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user


2
3
4
# File 'app/services/destroy_group_service.rb', line 2

def current_user
  @current_user
end

#groupObject

Returns the value of attribute group


2
3
4
# File 'app/services/destroy_group_service.rb', line 2

def group
  @group
end

Instance Method Details

#executeObject


8
9
10
11
12
13
14
15
16
# File 'app/services/destroy_group_service.rb', line 8

def execute
  group.projects.each do |project|
    # Skip repository removal because we remove directory with namespace
    # that contain all this repositories
    ::Projects::DestroyService.new(project, current_user, skip_repo: true).pending_delete!
  end

  group.destroy
end