Class: ArchUnit::Layers::Assertion::LayerDefinition
- Inherits:
-
Object
- Object
- ArchUnit::Layers::Assertion::LayerDefinition
- Defined in:
- lib/archunit/layers/assertion/layer_definition.rb
Overview
Immutable association between a layer name and its file selectors.
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name:, filters:) ⇒ LayerDefinition
constructor
A new instance of LayerDefinition.
- #matches?(file_path) ⇒ Boolean
- #with_filter(filter) ⇒ Object
Constructor Details
#initialize(name:, filters:) ⇒ LayerDefinition
Returns a new instance of LayerDefinition.
14 15 16 17 18 |
# File 'lib/archunit/layers/assertion/layer_definition.rb', line 14 def initialize(name:, filters:) @name = layer_name(name) @filters = filter_values(filters) freeze end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
12 13 14 |
# File 'lib/archunit/layers/assertion/layer_definition.rb', line 12 def filters @filters end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/archunit/layers/assertion/layer_definition.rb', line 12 def name @name end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
28 29 30 |
# File 'lib/archunit/layers/assertion/layer_definition.rb', line 28 def ==(other) other.is_a?(self.class) && name == other.name && filters == other.filters end |
#hash ⇒ Object
33 34 35 |
# File 'lib/archunit/layers/assertion/layer_definition.rb', line 33 def hash [self.class, name, filters].hash end |
#matches?(file_path) ⇒ Boolean
20 21 22 |
# File 'lib/archunit/layers/assertion/layer_definition.rb', line 20 def matches?(file_path) Common::PatternMatching.matches_any_pattern?(file_path, filters) end |
#with_filter(filter) ⇒ Object
24 25 26 |
# File 'lib/archunit/layers/assertion/layer_definition.rb', line 24 def with_filter(filter) self.class.new(name:, filters: [*filters, filter]) end |