Class: Todos::AllowedTargetFilterService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Allowable
Defined in:
app/services/todos/allowed_target_filter_service.rb

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?, #can_all?, #can_any?

Constructor Details

#initialize(todos, current_user) ⇒ AllowedTargetFilterService

Returns a new instance of AllowedTargetFilterService.



7
8
9
10
11
# File 'app/services/todos/allowed_target_filter_service.rb', line 7

def initialize(todos, current_user)
  @todos = todos
  @current_user = current_user
  @project_can_read_by_id = {}
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
# File 'app/services/todos/allowed_target_filter_service.rb', line 13

def execute
  Preloaders::ProjectPolicyPreloader.new(projects, @current_user).execute

  @todos.select do |todo|
    can_read_target_project?(todo) && can?(@current_user, :read_todo, todo)
  end
end