Module: ArchUnit::Common::FluentApi::Checkable
- Included in:
- Files::FluentApi::CustomFileCondition, Files::FluentApi::CycleFreeFileCondition, Files::FluentApi::DependOnExternalModuleCondition, Files::FluentApi::DependOnFileCondition, Files::FluentApi::MatchPatternFileCondition, Layers::FluentApi::LayeredArchitecture, Metrics::FluentApi::CustomMetricCondition, Metrics::FluentApi::MetricPredicateCondition, Metrics::FluentApi::MetricThresholdCondition, Metrics::FluentApi::ZoneCondition, Slices::FluentApi::DiagramSliceCondition, Slices::FluentApi::ForbiddenSliceDependencyCondition
- Defined in:
- lib/archunit/common/fluentapi/checkable.rb
Overview
The shared execution contract implemented by every terminal rule.
Instance Attribute Summary collapse
-
#rationale ⇒ String?
readonly
Optional normalized explanation, kept separate from violation values.
Instance Method Summary collapse
-
#because(reason) ⇒ Checkable
Explains why this completed rule exists, without changing the original.
-
#check(options = nil) ⇒ Array<ArchUnit::Violation>
Executes the rule and returns every architecture disagreement as structured data.
Instance Attribute Details
#rationale ⇒ String? (readonly)
Optional normalized explanation, kept separate from violation values.
16 17 18 |
# File 'lib/archunit/common/fluentapi/checkable.rb', line 16 def rationale @rationale end |
Instance Method Details
#because(reason) ⇒ Checkable
Explains why this completed rule exists, without changing the original. Append this after all selectors and modifiers.
22 23 24 25 26 27 28 29 30 |
# File 'lib/archunit/common/fluentapi/checkable.rb', line 22 def because(reason) unless reason.is_a?(String) && !reason.strip.empty? raise ArgumentError, 'reason must be a non-empty String' end copy = dup copy.instance_variable_set(:@rationale, reason.strip.freeze) copy.freeze end |
#check(options = nil) ⇒ Array<ArchUnit::Violation>
Executes the rule and returns every architecture disagreement as structured data.
35 36 37 38 39 40 41 42 43 |
# File 'lib/archunit/common/fluentapi/checkable.rb', line 35 def check( = nil) = CheckOptions.resolve() logger = Logging::CheckLogger.new(.logging) check_name = self.class.name || self.class.to_s logger.start_check(check_name) execute_check(, logger, check_name) ensure logger&.close end |
ArchUnitRuby