Class: Necropsy::ConventionRules::Rule
- Inherits:
-
Data
- Object
- Data
- Necropsy::ConventionRules::Rule
- Defined in:
- lib/necropsy/convention_rules.rb
Instance Attribute Summary collapse
-
#ancestor_patterns ⇒ Object
readonly
Returns the value of attribute ancestor_patterns.
-
#family ⇒ Object
readonly
Returns the value of attribute family.
-
#frameworks ⇒ Object
readonly
Returns the value of attribute frameworks.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#method_names ⇒ Object
readonly
Returns the value of attribute method_names.
-
#owner_patterns ⇒ Object
readonly
Returns the value of attribute owner_patterns.
Instance Method Summary collapse
-
#initialize(id:, family:, methods: [], owner_patterns: [], ancestor_patterns: [], frameworks: []) ⇒ Rule
constructor
A new instance of Rule.
Constructor Details
#initialize(id:, family:, methods: [], owner_patterns: [], ancestor_patterns: [], frameworks: []) ⇒ Rule
Returns a new instance of Rule.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/necropsy/convention_rules.rb', line 6 def initialize(id:, family:, methods: [], owner_patterns: [], ancestor_patterns: [], frameworks: []) id = id.to_s family = family.to_sym raise ArgumentError, 'rule id must not be empty' if id.empty? raise ArgumentError, 'rule family must not be empty' if family.to_s.empty? raise ArgumentError, 'rule methods must be bounded strings' unless Array(methods).all? do |name| name.is_a?(String) && !name.empty? && name.bytesize <= 128 end raise ArgumentError, 'rule owner patterns must be bounded strings' unless Array(owner_patterns).all? do |pattern| pattern.is_a?(String) && !pattern.empty? && pattern.bytesize <= 256 end raise ArgumentError, 'rule ancestor patterns must be bounded strings' unless Array(ancestor_patterns).all? do |pattern| pattern.is_a?(String) && !pattern.empty? && pattern.bytesize <= 256 end raise ArgumentError, 'rule frameworks must be bounded strings' unless Array(frameworks).all? do |name| name.is_a?(String) && !name.empty? && name.bytesize <= 64 end raise ArgumentError, 'rules may not be unscoped' if Array(owner_patterns).empty? && Array(ancestor_patterns).empty? super( id: id.freeze, family: family, method_names: Array(methods).map(&:to_s).uniq.sort.freeze, owner_patterns: Array(owner_patterns).map(&:to_s).uniq.sort.freeze, ancestor_patterns: Array(ancestor_patterns).map(&:to_s).uniq.sort.freeze, frameworks: Array(frameworks).map(&:to_s).uniq.sort.freeze ) end |
Instance Attribute Details
#ancestor_patterns ⇒ Object (readonly)
Returns the value of attribute ancestor_patterns
5 6 7 |
# File 'lib/necropsy/convention_rules.rb', line 5 def ancestor_patterns @ancestor_patterns end |
#family ⇒ Object (readonly)
Returns the value of attribute family
5 6 7 |
# File 'lib/necropsy/convention_rules.rb', line 5 def family @family end |
#frameworks ⇒ Object (readonly)
Returns the value of attribute frameworks
5 6 7 |
# File 'lib/necropsy/convention_rules.rb', line 5 def frameworks @frameworks end |
#id ⇒ Object (readonly)
Returns the value of attribute id
5 6 7 |
# File 'lib/necropsy/convention_rules.rb', line 5 def id @id end |
#method_names ⇒ Object (readonly)
Returns the value of attribute method_names
5 6 7 |
# File 'lib/necropsy/convention_rules.rb', line 5 def method_names @method_names end |
#owner_patterns ⇒ Object (readonly)
Returns the value of attribute owner_patterns
5 6 7 |
# File 'lib/necropsy/convention_rules.rb', line 5 def owner_patterns @owner_patterns end |