class ArchSpec::Rules::Naming::Requires
Requires each selected method to have a sibling named by a template, in the same component or another (on:), at a given scope. The template interpolates the selectorโs named captures, as in requires("without_%{base}"). Rule id naming.requires.
Public Class Methods
# File lib/archspec/rules/naming_rules.rb, line 101 def initialize(template, on: nil, scope: :instance, because: nil) @template = template @on = on @target_scope = scope @because = because end
Public Instance Methods
# File lib/archspec/rules/naming_rules.rb, line 112 def diagnostics(selected, rule, graph) target = @on || rule.source existing = existing_names(graph, target) selected.filter_map do |definition, match| sibling = expand(match) next if sibling.nil? || existing.include?(sibling.to_sym) Diagnostic.new( rule: id, message: message_for(definition, sibling, target, rule), location: definition.location, evidence: "#{definition.owner} defines ##{definition.name}, expected ##{sibling}" ) end end