Class: Todos::Destroy::PrivateFeaturesService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/todos/destroy/private_features_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_ids, user_id = nil) ⇒ PrivateFeaturesService

Returns a new instance of PrivateFeaturesService.


8
9
10
11
# File 'app/services/todos/destroy/private_features_service.rb', line 8

def initialize(project_ids, user_id = nil)
  @project_ids = project_ids
  @user_id = user_id
end

Instance Attribute Details

#project_idsObject (readonly)

Returns the value of attribute project_ids


6
7
8
# File 'app/services/todos/destroy/private_features_service.rb', line 6

def project_ids
  @project_ids
end

#user_idObject (readonly)

Returns the value of attribute user_id


6
7
8
# File 'app/services/todos/destroy/private_features_service.rb', line 6

def user_id
  @user_id
end

Instance Method Details

#executeObject

rubocop: disable CodeReuse/ActiveRecord


14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/todos/destroy/private_features_service.rb', line 14

def execute
  ProjectFeature.where(project_id: project_ids).each do |project_features|
    target_types = []
    target_types << Issue.name if private?(project_features.issues_access_level)
    target_types << MergeRequest.name if private?(project_features.merge_requests_access_level)
    target_types << Commit.name if private?(project_features.repository_access_level)

    next if target_types.empty?

    remove_todos(project_features.project_id, target_types)
  end
end