Module: BaseServiceUtility

Instance Method Summary collapse

Methods included from Gitlab::Allowable

#can?

Instance Method Details

#deny_visibility_level(model, denied_visibility_level = nil) ⇒ Object

Add an error to the specified model for restricted visibility levels


36
37
38
39
40
41
42
# File 'app/services/concerns/base_service_utility.rb', line 36

def deny_visibility_level(model, denied_visibility_level = nil)
  denied_visibility_level ||= model.visibility_level

  level_name = Gitlab::VisibilityLevel.level_name(denied_visibility_level).downcase

  model.errors.add(:visibility_level, "#{level_name} has been restricted by your GitLab administrator")
end

#event_serviceObject


13
14
15
# File 'app/services/concerns/base_service_utility.rb', line 13

def event_service
  EventCreateService.new
end

#log_error(message) ⇒ Object


31
32
33
# File 'app/services/concerns/base_service_utility.rb', line 31

def log_error(message)
  Gitlab::AppLogger.error message
end

#log_info(message) ⇒ Object

Logging


27
28
29
# File 'app/services/concerns/base_service_utility.rb', line 27

def log_info(message)
  Gitlab::AppLogger.info message
end

#notification_serviceObject

Convenience service methods


9
10
11
# File 'app/services/concerns/base_service_utility.rb', line 9

def notification_service
  NotificationService.new
end

#system_hook_serviceObject


21
22
23
# File 'app/services/concerns/base_service_utility.rb', line 21

def system_hook_service
  SystemHooksService.new
end

#todo_serviceObject


17
18
19
# File 'app/services/concerns/base_service_utility.rb', line 17

def todo_service
  TodoService.new
end

#visibility_levelObject


44
45
46
# File 'app/services/concerns/base_service_utility.rb', line 44

def visibility_level
  params[:visibility].is_a?(String) ? Gitlab::VisibilityLevel.level_value(params[:visibility]) : params[:visibility_level]
end