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.



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

def initialize(resource, condition, network = nil)
  super(resource, { ruby: condition })

  @network = network
end

Class Method Details

.limiter_parametersObject



11
12
13
# File 'lib/gitlab/triage/filters/ruby_conditions_filter.rb', line 11

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

Instance Method Details

#calculateObject



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

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

  !!context.eval(@expression)
end

#initialize_variables(condition) ⇒ Object (private)



29
30
31
# File 'lib/gitlab/triage/filters/ruby_conditions_filter.rb', line 29

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