Class: Contrast::Agent::Protect::Rule::InputClassification::MatchRates
- Defined in:
- lib/contrast/agent/protect/rule/input_classification/match_rates.rb
Overview
This class will hold match information when input classification is being saved in LRU cache.
Constant Summary
Constants inherited from Rates
Rates::FIELD_NAME, Rates::TEST_NAME
Instance Attribute Summary collapse
- #input_matches ⇒ Integer readonly
- #input_mismatches ⇒ Integer readonly
- #request_matches ⇒ Integer readonly
- #score_level ⇒ String readonly
Attributes inherited from Rates
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#increase_match_for_input ⇒ Object
Increase the match count for the given rule_id and input.
-
#increase_match_for_request ⇒ Object
increase the missmatch count for the given rule_id and input.
- #increase_mismatch_for_input ⇒ Object
-
#initialize(rule_id, input_type, score_level) ⇒ MatchRates
constructor
A new instance of MatchRates.
-
#to_fields ⇒ Hash
Returns Agent Telemetry reportable fields.
Constructor Details
#initialize(rule_id, input_type, score_level) ⇒ MatchRates
Returns a new instance of MatchRates.
25 26 27 28 29 30 31 |
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 25 def initialize rule_id, input_type, score_level super(rule_id, input_type) @input_matches = 0 @request_matches = 0 @input_mismatches = 0 @score_level = score_level if Contrast::Agent::Reporting::ScoreLevel.to_a.include?(score_level) end |
Instance Attribute Details
#input_matches ⇒ Integer (readonly)
14 15 16 |
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 14 def input_matches @input_matches end |
#input_mismatches ⇒ Integer (readonly)
16 17 18 |
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 16 def input_mismatches @input_mismatches end |
#request_matches ⇒ Integer (readonly)
18 19 20 |
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 18 def request_matches @request_matches end |
#score_level ⇒ String (readonly)
20 21 22 |
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 20 def score_level @score_level end |
Instance Method Details
#empty? ⇒ Boolean
47 48 49 |
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 47 def empty? super && @input_matches.zero? && @input_mismatches.zero? && @request_matches.zero? end |
#increase_match_for_input ⇒ Object
Increase the match count for the given rule_id and input.
34 35 36 |
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 34 def increase_match_for_input @input_matches += 1 end |
#increase_match_for_request ⇒ Object
increase the missmatch count for the given rule_id and input.
43 44 45 |
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 43 def increase_match_for_request @request_matches += 1 end |
#increase_mismatch_for_input ⇒ Object
38 39 40 |
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 38 def increase_mismatch_for_input @input_mismatches += 1 end |
#to_fields ⇒ Hash
Returns Agent Telemetry reportable fields.
54 55 56 57 58 59 60 |
# File 'lib/contrast/agent/protect/rule/input_classification/match_rates.rb', line 54 def to_fields { "#{ to_field_title }.input_matches" => input_matches, "#{ to_field_title }.input_mismatches" => input_mismatches, "#{ to_field_title }.request_matches" => request_matches } end |