Class: ArchUnit::Metrics::Assertion::MetricThresholdViolation

Inherits:
Common::Assertion::Violation show all
Defined in:
lib/archunit/metrics/assertion/metric_threshold.rb

Overview

One metric value that did not meet its numeric threshold.

Constant Summary collapse

COMPARISONS =
%i[below above equal below_or_equal above_or_equal].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject:, metric_name:, value:, threshold:, comparison:) ⇒ MetricThresholdViolation

Returns a new instance of MetricThresholdViolation.



17
18
19
20
21
22
23
24
# File 'lib/archunit/metrics/assertion/metric_threshold.rb', line 17

def initialize(subject:, metric_name:, value:, threshold:, comparison:)
  @subject = validated_subject(subject)
  @metric_name = immutable_metric_name(metric_name)
  @value = Calculation::NumericValue.validate(value)
  @threshold = Calculation::NumericValue.validate(threshold, attribute: 'threshold')
  @comparison = validated_comparison(comparison)
  super()
end

Instance Attribute Details

#comparisonObject (readonly)

Returns the value of attribute comparison.



15
16
17
# File 'lib/archunit/metrics/assertion/metric_threshold.rb', line 15

def comparison
  @comparison
end

#metric_nameObject (readonly)

Returns the value of attribute metric_name.



15
16
17
# File 'lib/archunit/metrics/assertion/metric_threshold.rb', line 15

def metric_name
  @metric_name
end

#subjectObject (readonly)

Returns the value of attribute subject.



15
16
17
# File 'lib/archunit/metrics/assertion/metric_threshold.rb', line 15

def subject
  @subject
end

#thresholdObject (readonly)

Returns the value of attribute threshold.



15
16
17
# File 'lib/archunit/metrics/assertion/metric_threshold.rb', line 15

def threshold
  @threshold
end

#valueObject (readonly)

Returns the value of attribute value.



15
16
17
# File 'lib/archunit/metrics/assertion/metric_threshold.rb', line 15

def value
  @value
end

Instance Method Details

#identifierObject



26
27
28
# File 'lib/archunit/metrics/assertion/metric_threshold.rb', line 26

def identifier
  subject.identifier
end