debian-mirror-gitlab/app/services/timelogs/base_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
643 B
Ruby
Raw Normal View History

2022-07-16 23:28:13 +05:30
# frozen_string_literal: true
module Timelogs
class BaseService
include BaseServiceUtility
include Gitlab::Utils::StrongMemoize
2022-08-27 11:52:29 +05:30
attr_accessor :current_user
2022-07-16 23:28:13 +05:30
2022-08-27 11:52:29 +05:30
def initialize(user)
2022-07-16 23:28:13 +05:30
@current_user = user
end
2022-08-27 11:52:29 +05:30
def success(timelog)
ServiceResponse.success(payload: {
timelog: timelog
})
end
def error(message, http_status = nil)
ServiceResponse.error(message: message, http_status: http_status)
end
def error_in_save(timelog)
return error(_("Failed to save timelog")) if timelog.errors.empty?
error(timelog.errors.full_messages.to_sentence)
end
2022-07-16 23:28:13 +05:30
end
end