Class: ArchSpec::Rules::DependencyRule
- Inherits:
-
Object
- Object
- ArchSpec::Rules::DependencyRule
- Defined in:
- lib/archspec/rules/dependency_rules.rb
Overview
Base for the allow and forbid dependency rules. Merges repeated declarations for the same source component.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
-
#initialize(source, targets) ⇒ DependencyRule
constructor
A new instance of DependencyRule.
- #merge!(other) ⇒ Object
- #merge_key ⇒ Object
Constructor Details
#initialize(source, targets) ⇒ DependencyRule
Returns a new instance of DependencyRule.
15 16 17 18 |
# File 'lib/archspec/rules/dependency_rules.rb', line 15 def initialize(source, targets) @source = source.to_sym @targets = Array(targets).flatten.map(&:to_sym).to_set end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
13 14 15 |
# File 'lib/archspec/rules/dependency_rules.rb', line 13 def source @source end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
13 14 15 |
# File 'lib/archspec/rules/dependency_rules.rb', line 13 def targets @targets end |
Instance Method Details
#merge!(other) ⇒ Object
24 25 26 27 |
# File 'lib/archspec/rules/dependency_rules.rb', line 24 def merge!(other) targets.merge(other.targets) self end |
#merge_key ⇒ Object
20 21 22 |
# File 'lib/archspec/rules/dependency_rules.rb', line 20 def merge_key [self.class, source] end |