Class: BaseContainerService

Inherits:
Object
  • Object
show all
Includes:
BaseServiceUtility
Defined in:
app/services/base_container_service.rb

Overview

Base class, scoped by container (project or group).

New or existing services which only require a project or group container should subclass BaseProjectService or BaseGroupService.

If you require a different but specific, non-polymorphic container consider creating a new subclass, and update the related comment at the top of the original BaseService.

Instance Attribute Summary collapse

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(container:, current_user: nil, params: {}) ⇒ BaseContainerService

Returns a new instance of BaseContainerService.


16
17
18
19
20
# File 'app/services/base_container_service.rb', line 16

def initialize(container:, current_user: nil, params: {})
  @container = container
  @current_user = current_user
  @params = params.dup
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.


14
15
16
# File 'app/services/base_container_service.rb', line 14

def container
  @container
end

#current_userObject (readonly)

Returns the value of attribute current_user.


14
15
16
# File 'app/services/base_container_service.rb', line 14

def current_user
  @current_user
end

#paramsObject (readonly)

Returns the value of attribute params.


14
15
16
# File 'app/services/base_container_service.rb', line 14

def params
  @params
end

Instance Method Details

#group_container?Boolean

Returns:

  • (Boolean)

26
27
28
# File 'app/services/base_container_service.rb', line 26

def group_container?
  container.is_a?(::Group)
end

#namespace_container?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'app/services/base_container_service.rb', line 30

def namespace_container?
  container.is_a?(::Namespace)
end

#project_container?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'app/services/base_container_service.rb', line 22

def project_container?
  container.is_a?(::Project)
end