debian-mirror-gitlab/app/services/protected_refs/access_level_params.rb

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

38 lines
824 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2022-08-13 15:12:31 +05:30
module ProtectedRefs
2018-03-17 18:26:18 +05:30
class AccessLevelParams
attr_reader :type, :params
2023-01-13 00:05:48 +05:30
def initialize(type, params, with_defaults: true)
2018-03-17 18:26:18 +05:30
@type = type
2023-01-13 00:05:48 +05:30
@params = with_defaults ? params_with_default(params) : params
2018-03-17 18:26:18 +05:30
end
def access_levels
ce_style_access_level
end
private
def params_with_default(params)
2018-11-18 11:00:15 +05:30
params[:"#{type}_access_level"] ||= Gitlab::Access::MAINTAINER if use_default_access_level?(params)
2018-03-17 18:26:18 +05:30
params
end
def use_default_access_level?(params)
true
end
def ce_style_access_level
access_level = params[:"#{type}_access_level"]
return [] unless access_level
[{ access_level: access_level }]
end
end
end
2019-12-04 20:38:33 +05:30
2022-08-13 15:12:31 +05:30
ProtectedRefs::AccessLevelParams.prepend_mod_with('ProtectedRefs::AccessLevelParams')