Class: ArchUnit::Metrics::Assertion::MetricPredicateViolation

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

Overview

One built-in metric value that did not satisfy a user predicate.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject:, metric_name:, value:) ⇒ MetricPredicateViolation

Returns a new instance of MetricPredicateViolation.



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

def initialize(subject:, metric_name:, value:)
  unless subject.respond_to?(:identifier)
    raise ArgumentError, 'subject must expose an identifier'
  end

  @subject = subject
  @metric_name = immutable_metric_name(metric_name)
  @value = Calculation::NumericValue.validate(value)
  super()
end

Instance Attribute Details

#metric_nameObject (readonly)

Returns the value of attribute metric_name.



13
14
15
# File 'lib/archunit/metrics/assertion/metric_predicate.rb', line 13

def metric_name
  @metric_name
end

#subjectObject (readonly)

Returns the value of attribute subject.



13
14
15
# File 'lib/archunit/metrics/assertion/metric_predicate.rb', line 13

def subject
  @subject
end

#valueObject (readonly)

Returns the value of attribute value.



13
14
15
# File 'lib/archunit/metrics/assertion/metric_predicate.rb', line 13

def value
  @value
end

Instance Method Details

#identifierObject



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

def identifier
  subject.identifier
end