class ArchSpec::ConcernSemantics
Normalizes the explicit ActiveSupport::Concern DSL after semantic indexing. Callback bodies retain lexical constant references, but their mixins and methods are installed on the consumer. No application code is executed. Source ownership is normalized here; established effects are emitted through Facts::Builder, using the same application path as external producers.
Constants
- Callback
- MIXINS
- ModuleBody
Public Class Methods
Source
# File lib/archspec/concern_semantics.rb, line 14 def initialize @modules = [] @callbacks = Hash.new { |hash, key| hash[key] = [] } @dependencies = Hash.new { |hash, key| hash[key] = [] } end
Public Instance Methods
Source
# File lib/archspec/concern_semantics.rb, line 24 def apply(graph) @graph = graph @mixin_edges = graph.edges.select { |edge| MIXINS.key?(edge.type) } .group_by { |edge| [edge.from_constant, edge.from_path] } @concerns = @modules.select { |mod| extends_concern?(mod) }.map(&:name).to_set return if @concerns.empty? @facts = Facts::Builder.new(graph, producer: 'active_support_concern') normalize_blocks defer_dependencies rebuild_mixins install_consumers @concerns.each do |name| source = graph.constants_named("#{name}::ClassMethods").first @facts.expose_methods(source: source, owner: graph.constants_named(name).first, scope: :class) if source end @facts.apply end
# File lib/archspec/concern_semantics.rb, line 20 def record_module(name, path, body) @modules << ModuleBody.new(name, path, body) if body.is_a?(Prism::StatementsNode) end