Class: Users::BlockService

Inherits:
BaseService show all
Defined in:
app/services/users/block_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(current_user) ⇒ BlockService

Returns a new instance of BlockService.


5
6
7
# File 'app/services/users/block_service.rb', line 5

def initialize(current_user)
  @current_user = current_user
end

Instance Method Details

#execute(user) ⇒ Object


9
10
11
12
13
14
15
16
17
# File 'app/services/users/block_service.rb', line 9

def execute(user)
  if user.block
    after_block_hook(user)
    success
  else
    messages = user.errors.full_messages
    error(messages.uniq.join('. '))
  end
end