Class: ProtectableDropdown
- Inherits:
-
Object
- Object
- ProtectableDropdown
- Defined in:
- app/models/protectable_dropdown.rb
Constant Summary collapse
- REF_TYPES =
%i[branches tags].freeze
- REF_NAME_METHODS =
{ branches: :branch_names, tags: :tag_names }.freeze
Instance Method Summary collapse
- #array ⇒ Object
-
#initialize(project, ref_type, ref_names: nil) ⇒ ProtectableDropdown
constructor
A new instance of ProtectableDropdown.
-
#protectable_ref_names ⇒ Object
Tags/branches which are yet to be individually protected.
Constructor Details
#initialize(project, ref_type, ref_names: nil) ⇒ ProtectableDropdown
Returns a new instance of ProtectableDropdown.
10 11 12 13 14 15 16 |
# File 'app/models/protectable_dropdown.rb', line 10 def initialize(project, ref_type, ref_names: nil) raise ArgumentError, "invalid ref type `#{ref_type}`" unless ref_type.in?(REF_TYPES) @project = project @ref_type = ref_type @ref_names = ref_names.presence || get_ref_names end |
Instance Method Details
#array ⇒ Object
25 26 27 |
# File 'app/models/protectable_dropdown.rb', line 25 def array protectable_ref_names.map { |ref_name| { text: ref_name, id: ref_name, title: ref_name } } end |
#protectable_ref_names ⇒ Object
Tags/branches which are yet to be individually protected
19 20 21 22 23 |
# File 'app/models/protectable_dropdown.rb', line 19 def protectable_ref_names return [] if @project.empty_repo? @protectable_ref_names ||= ref_names - non_wildcard_protected_ref_names end |