Class: Timelogs::BaseService
- Inherits:
-
Object
- Object
- Timelogs::BaseService
- Includes:
- BaseServiceUtility, Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/timelogs/base_service.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
Instance Method Summary collapse
- #error(message, http_status = nil) ⇒ Object
- #error_in_save(timelog) ⇒ Object
-
#initialize(user) ⇒ BaseService
constructor
A new instance of BaseService.
- #success(timelog) ⇒ Object
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
Constructor Details
#initialize(user) ⇒ BaseService
Returns a new instance of BaseService.
10 11 12 |
# File 'app/services/timelogs/base_service.rb', line 10 def initialize(user) @current_user = user end |
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
8 9 10 |
# File 'app/services/timelogs/base_service.rb', line 8 def current_user @current_user end |
Instance Method Details
#error(message, http_status = nil) ⇒ Object
20 21 22 |
# File 'app/services/timelogs/base_service.rb', line 20 def error(, http_status = nil) ServiceResponse.error(message: , http_status: http_status) end |
#error_in_save(timelog) ⇒ Object
24 25 26 27 28 |
# File 'app/services/timelogs/base_service.rb', line 24 def error_in_save(timelog) return error(_("Failed to save timelog"), 404) if timelog.errors.empty? error(timelog.errors..to_sentence, 404) end |
#success(timelog) ⇒ Object
14 15 16 17 18 |
# File 'app/services/timelogs/base_service.rb', line 14 def success(timelog) ServiceResponse.success(payload: { timelog: timelog }) end |