Class: ProtectableDropdown

Inherits:
Object
  • Object
show all
Defined in:
app/models/protectable_dropdown.rb

Constant Summary collapse

REF_TYPES =
%i[branches tags].freeze

Instance Method Summary collapse

Constructor Details

#initialize(project, ref_type) ⇒ ProtectableDropdown

Returns a new instance of ProtectableDropdown.

Raises:

  • (ArgumentError)

6
7
8
9
10
11
# File 'app/models/protectable_dropdown.rb', line 6

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

#hashObject


18
19
20
# File 'app/models/protectable_dropdown.rb', line 18

def hash
  protectable_ref_names.map { |ref_name| { text: ref_name, id: ref_name, title: ref_name } }
end

#protectable_ref_namesObject

Tags/branches which are yet to be individually protected


14
15
16
# File 'app/models/protectable_dropdown.rb', line 14

def protectable_ref_names
  @protectable_ref_names ||= ref_names - non_wildcard_protected_ref_names
end