Class: Gitlab::Triage::Filters::BaseConditionsFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/triage/filters/base_conditions_filter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, condition) ⇒ BaseConditionsFilter

Returns a new instance of BaseConditionsFilter.



8
9
10
11
12
# File 'lib/gitlab/triage/filters/base_conditions_filter.rb', line 8

def initialize(resource, condition)
  @resource = resource
  validate_condition(condition)
  initialize_variables(condition)
end

Class Method Details

.all_params_filter_namesObject



30
31
32
# File 'lib/gitlab/triage/filters/base_conditions_filter.rb', line 30

def self.all_params_filter_names
  params_filter_names
end

.filter_parametersObject



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

def self.filter_parameters
  []
end

.params_check_for_field(field) ⇒ Object



42
43
44
45
46
# File 'lib/gitlab/triage/filters/base_conditions_filter.rb', line 42

def self.params_check_for_field(field)
  filter_parameters.select do |param|
    param[field].present?
  end
end

.params_checking_condition_typeObject



38
39
40
# File 'lib/gitlab/triage/filters/base_conditions_filter.rb', line 38

def self.params_checking_condition_type
  params_filter_names params_check_for_field(:type)
end

.params_checking_condition_valueObject



34
35
36
# File 'lib/gitlab/triage/filters/base_conditions_filter.rb', line 34

def self.params_checking_condition_value
  params_filter_names params_check_for_field(:values)
end

.params_filter_names(params = nil) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/gitlab/triage/filters/base_conditions_filter.rb', line 22

def self.params_filter_names(params = nil)
  params ||= filter_parameters

  params.map do |param|
    param[:name]
  end
end

Instance Method Details

#calculateObject

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/gitlab/triage/filters/base_conditions_filter.rb', line 14

def calculate
  raise NotImplementedError
end

#initialize_variables(condition) ⇒ Object (private)



54
# File 'lib/gitlab/triage/filters/base_conditions_filter.rb', line 54

def initialize_variables(condition); end

#validate_condition(condition) ⇒ Object (private)



50
51
52
# File 'lib/gitlab/triage/filters/base_conditions_filter.rb', line 50

def validate_condition(condition)
  ParamsValidator.new(self.class.filter_parameters, condition).validate!
end