2020-05-07 14:09:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-05-11 23:10:21 -04:00
|
|
|
# Base class, scoped by container (project or group).
|
|
|
|
#
|
2021-09-14 11:12:05 -04:00
|
|
|
# New or existing services which only require a project or group container
|
|
|
|
# should subclass BaseProjectService or BaseGroupService.
|
2021-05-11 23:10:21 -04:00
|
|
|
#
|
2021-09-14 11:12:05 -04:00
|
|
|
# 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.
|
2020-05-07 14:09:28 -04:00
|
|
|
class BaseContainerService
|
|
|
|
include BaseServiceUtility
|
|
|
|
|
|
|
|
attr_reader :container, :current_user, :params
|
|
|
|
|
|
|
|
def initialize(container:, current_user: nil, params: {})
|
2021-04-19 17:09:27 -04:00
|
|
|
@container = container
|
|
|
|
@current_user = current_user
|
|
|
|
@params = params.dup
|
2020-05-07 14:09:28 -04:00
|
|
|
end
|
2021-05-20 23:10:24 -04:00
|
|
|
|
|
|
|
def project_container?
|
|
|
|
container.is_a?(::Project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def group_container?
|
|
|
|
container.is_a?(::Group)
|
|
|
|
end
|
2020-05-07 14:09:28 -04:00
|
|
|
end
|