Class: Gitlab::Triage::Filters::RubyConditionsFilter

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseConditionsFilter

all_params_filter_names, filter_parameters, params_check_for_field, params_checking_condition_type, params_checking_condition_value, params_filter_names, #validate_condition

Constructor Details

#initialize(resource, condition, network = nil) ⇒ RubyConditionsFilter

Returns a new instance of RubyConditionsFilter.



13
14
15
16
17
# File 'lib/gitlab/triage/filters/ruby_conditions_filter.rb', line 13

def initialize(resource, condition, network = nil)
  super(resource, condition)

  @network = network
end

Class Method Details

.limiter_parametersObject



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

def self.limiter_parameters
  [{ name: :ruby, type: String }]
end

Instance Method Details

#calculateObject



19
20
21
22
23
# File 'lib/gitlab/triage/filters/ruby_conditions_filter.rb', line 19

def calculate
  context = Resource::Context.build(@resource, network: @network, redact_confidentials: false)

  !!context.eval(@expression)
end

#initialize_variables(condition) ⇒ Object (private)



27
28
29
# File 'lib/gitlab/triage/filters/ruby_conditions_filter.rb', line 27

def initialize_variables(condition)
  @expression = condition[:ruby]
end