Class: ArchUnit::Metrics::FluentApi::MetricThresholdCondition

Inherits:
Object
  • Object
show all
Includes:
Common::FluentApi::Checkable
Defined in:
lib/archunit/metrics/fluentapi/metric_threshold_condition.rb

Overview

Executable numeric threshold over one selected metric.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common::FluentApi::Checkable

#check

Constructor Details

#initialize(selection:, comparison:, threshold:) ⇒ MetricThresholdCondition

Returns a new instance of MetricThresholdCondition.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/archunit/metrics/fluentapi/metric_threshold_condition.rb', line 15

def initialize(selection:, comparison:, threshold:)
  unless selection.is_a?(MetricSelection)
    raise ArgumentError, 'selection must be a MetricSelection'
  end
  unless Assertion::MetricThresholdViolation::COMPARISONS.include?(comparison)
    raise ArgumentError, "unknown metric comparison: #{comparison.inspect}"
  end

  @selection = selection
  @comparison = comparison
  @threshold = Calculation::NumericValue.validate(threshold, attribute: 'threshold')
  freeze
end

Instance Attribute Details

#comparisonObject (readonly)

Returns the value of attribute comparison.



13
14
15
# File 'lib/archunit/metrics/fluentapi/metric_threshold_condition.rb', line 13

def comparison
  @comparison
end

#selectionObject (readonly)

Returns the value of attribute selection.



13
14
15
# File 'lib/archunit/metrics/fluentapi/metric_threshold_condition.rb', line 13

def selection
  @selection
end

#thresholdObject (readonly)

Returns the value of attribute threshold.



13
14
15
# File 'lib/archunit/metrics/fluentapi/metric_threshold_condition.rb', line 13

def threshold
  @threshold
end