Class: Gitlab::QuickActions::UsersExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/quick_actions/users_extractor.rb

Constant Summary collapse

MAX_QUICK_ACTION_USERS =
100
Error =
Class.new(ArgumentError)
TooManyError =
Class.new(Error) do
  def limit
    MAX_QUICK_ACTION_USERS
  end
end
MissingError =
Class.new(Error)
TooManyFoundError =
Class.new(TooManyError)
TooManyRefsError =
Class.new(TooManyError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_user, project:, group:, target:, text:) ⇒ UsersExtractor

Returns a new instance of UsersExtractor.



21
22
23
24
25
26
27
# File 'lib/gitlab/quick_actions/users_extractor.rb', line 21

def initialize(current_user, project:, group:, target:, text:)
  @current_user = current_user
  @project = project
  @group = group
  @target = target
  @text = text
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



19
20
21
# File 'lib/gitlab/quick_actions/users_extractor.rb', line 19

def current_user
  @current_user
end

#groupObject (readonly)

Returns the value of attribute group.



19
20
21
# File 'lib/gitlab/quick_actions/users_extractor.rb', line 19

def group
  @group
end

#projectObject (readonly)

Returns the value of attribute project.



19
20
21
# File 'lib/gitlab/quick_actions/users_extractor.rb', line 19

def project
  @project
end

#targetObject (readonly)

Returns the value of attribute target.



19
20
21
# File 'lib/gitlab/quick_actions/users_extractor.rb', line 19

def target
  @target
end

#textObject (readonly)

Returns the value of attribute text.



19
20
21
# File 'lib/gitlab/quick_actions/users_extractor.rb', line 19

def text
  @text
end

Instance Method Details

#executeObject



29
30
31
32
33
34
35
36
37
# File 'lib/gitlab/quick_actions/users_extractor.rb', line 29

def execute
  return [] unless text.present?

  users = collect_users

  check_users!(users)

  users
end