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
- #hash ⇒ Object
-
#initialize(project, ref_type) ⇒ 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) ⇒ ProtectableDropdown
Returns a new instance of ProtectableDropdown.
10 11 12 13 14 15 |
# File 'app/models/protectable_dropdown.rb', line 10 def initialize(project, ref_type) raise ArgumentError, "invalid ref type `#{ref_type}`" unless ref_type.in?(REF_TYPES) @project = project @ref_type = ref_type end |
Instance Method Details
#hash ⇒ Object
24 25 26 |
# File 'app/models/protectable_dropdown.rb', line 24 def hash 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
18 19 20 21 22 |
# File 'app/models/protectable_dropdown.rb', line 18 def protectable_ref_names return [] if @project.empty_repo? @protectable_ref_names ||= ref_names - non_wildcard_protected_ref_names end |