class ArchSpec::Rules::MustImplementOneOfRule
Backs ArchSpec::DSL::ComponentProxy#must_implement_one_of. Flags classes that implement none of the named methods.
Attributes
Public Class Methods
Source
# File lib/archspec/rules/protocol_rules.rb, line 108 def initialize(source, method_names) @source = source.to_sym @method_names = Array(method_names).flatten.map(&:to_sym) end
Public Instance Methods
Source
# File lib/archspec/rules/protocol_rules.rb, line 126 def evaluate(graph) constants_for(graph).filter_map do |constant| methods, unresolved = graph.effective_instance_methods(constant.name) next if method_names.any? { |method_name| methods.include?(method_name) } Diagnostic.new( rule: id, message: "#{constant.name} must implement one of #{method_names.map { |name| "##{name}" }.join(', ')}", location: constant.location, evidence: ProtocolEvidence.for(constant, methods, unresolved), confidence: unresolved.empty? ? :high : :medium ) end end
Source
# File lib/archspec/rules/protocol_rules.rb, line 122 def id 'protocol.must_implement_one_of' end
Source
# File lib/archspec/rules/protocol_rules.rb, line 117 def merge!(other) @method_names |= other.method_names self end
Source
# File lib/archspec/rules/protocol_rules.rb, line 113 def merge_key [self.class, source] end