class ArchSpec::Rules::CannotDefineMethodRule
Backs ArchSpec::DSL::ComponentProxy#cannot_define. Flags method definitions in the component matching the named methods.
Attributes
Public Class Methods
Source
# File lib/archspec/rules/protocol_rules.rb, line 173 def initialize(source, methods) @source = source.to_sym @method_names = Array(methods).flatten.map(&:to_sym) end
Public Instance Methods
Source
# File lib/archspec/rules/protocol_rules.rb, line 191 def evaluate(graph) graph.method_definitions_for_component(source).filter_map do |method_definition| next unless method_names.include?(method_definition.name) Diagnostic.new( rule: id, message: "#{source} must not define ##{method_definition.name}", location: method_definition.location, evidence: "#{method_definition.owner} defines #{method_definition.scope} method #{method_definition.name}" ) end end
Source
# File lib/archspec/rules/protocol_rules.rb, line 187 def id 'methods.define_forbid' end
Source
# File lib/archspec/rules/protocol_rules.rb, line 182 def merge!(other) @method_names |= other.method_names self end
Source
# File lib/archspec/rules/protocol_rules.rb, line 178 def merge_key [self.class, source] end