Module: ArchUnit::Metrics::FluentApi::LoggedMetric

Defined in:
lib/archunit/metrics/fluentapi/logged_metric.rb

Overview

Observes the existing calculation once, including values that pass the rule.

Class Method Summary collapse

Class Method Details

.wrap(metric) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/archunit/metrics/fluentapi/logged_metric.rb', line 10

def self.wrap(metric)
  logger = Common::Logging::Inspection.logger
  return metric unless logger&.debug?

  metric.with(calculation: lambda do |subject|
    value = metric.calculate(subject)
    logger.log_metric(name: metric.name, value:, subject: subject.identifier)
    value
  end)
end