Class: SavedReplies::UpdateService

Inherits:
BaseService show all
Defined in:
app/services/saved_replies/update_service.rb

Constant Summary

Constants inherited from BaseService

BaseService::UnauthorizedError

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?, #can_all?, #can_any?

Constructor Details

#initialize(saved_reply:, name:, content:) ⇒ UpdateService

Returns a new instance of UpdateService.



5
6
7
8
9
# File 'app/services/saved_replies/update_service.rb', line 5

def initialize(saved_reply:, name:, content:)
  @saved_reply = saved_reply
  @name = name
  @content = content
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
# File 'app/services/saved_replies/update_service.rb', line 11

def execute
  if saved_reply.update(name: name, content: content)
    success(saved_reply: saved_reply.reset)
  else
    error(saved_reply.errors.full_messages)
  end
end