Class: Gitlab::Triage::Filters::NoAdditionalLabelsConditionsFilter

Inherits:
BaseConditionsFilter show all
Defined in:
lib/gitlab/triage/filters/no_additional_labels_conditions_filter.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseConditionsFilter

all_params_filter_names, #initialize, params_check_for_field, params_checking_condition_type, params_checking_condition_value, params_filter_names

Constructor Details

This class inherits a constructor from Gitlab::Triage::Filters::BaseConditionsFilter

Class Method Details

.filter_parametersObject



9
10
11
# File 'lib/gitlab/triage/filters/no_additional_labels_conditions_filter.rb', line 9

def self.filter_parameters
  []
end

Instance Method Details

#calculateObject



26
27
28
# File 'lib/gitlab/triage/filters/no_additional_labels_conditions_filter.rb', line 26

def calculate
  (resource_value - @expected_labels).empty?
end

#initialize_variables(expected_labels) ⇒ Object



17
18
19
20
# File 'lib/gitlab/triage/filters/no_additional_labels_conditions_filter.rb', line 17

def initialize_variables(expected_labels)
  @attribute = :labels
  @expected_labels = expected_labels
end

#resource_valueObject



22
23
24
# File 'lib/gitlab/triage/filters/no_additional_labels_conditions_filter.rb', line 22

def resource_value
  @resource[@attribute]
end

#validate_condition(condition) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
# File 'lib/gitlab/triage/filters/no_additional_labels_conditions_filter.rb', line 13

def validate_condition(condition)
  raise ArgumentError, 'condition must be an array containing the only label values allowed' unless condition.is_a?(Array)
end