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?

Constructor Details

#initialize(todos, current_user) ⇒ AllowedTargetFilterService

Returns a new instance of AllowedTargetFilterService.


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

def initialize(todos, current_user)
  @todos = todos
  @current_user = current_user
end

Instance Method Details

#executeObject


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

def execute
  Preloaders::UserMaxAccessLevelInProjectsPreloader.new(@todos.map(&:project).compact, @current_user).execute

  @todos.select { |todo| can?(@current_user, :read_todo, todo) }
end