Class: Users::SetStatusService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(current_user, params) ⇒ SetStatusService

Returns a new instance of SetStatusService.


9
10
11
12
13
# File 'app/services/users/set_status_service.rb', line 9

def initialize(current_user, params)
  @current_user = current_user
  @params = params.dup
  @target_user = params.delete(:user) || current_user
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.


7
8
9
# File 'app/services/users/set_status_service.rb', line 7

def current_user
  @current_user
end

#paramsObject (readonly)

Returns the value of attribute params.


7
8
9
# File 'app/services/users/set_status_service.rb', line 7

def params
  @params
end

#target_userObject (readonly)

Returns the value of attribute target_user.


7
8
9
# File 'app/services/users/set_status_service.rb', line 7

def target_user
  @target_user
end

Instance Method Details

#executeObject


15
16
17
18
19
20
21
22
23
# File 'app/services/users/set_status_service.rb', line 15

def execute
  return false unless can?(current_user, :update_user_status, target_user)

  if status_cleared?
    remove_status
  else
    set_status
  end
end