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.
Constants
- Callback
- MIXINS
- ModuleBody
Public Class Methods
Source
# File lib/archspec/concern_semantics.rb, line 12 def initialize @modules = [] @callbacks = Hash.new { |hash, key| hash[key] = [] } @dependencies = Hash.new { |hash, key| hash[key] = [] } @callback_calls = [] end
Public Instance Methods
Source
# File lib/archspec/concern_semantics.rb, line 23 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? normalize_blocks defer_dependencies rebuild_mixins install_consumers @concerns.each do |name| graph.expose_instance_methods("#{name}::ClassMethods", as_owner: name, scope: :class) end graph.clear_method_caches apply_callback_receivers end
# File lib/archspec/concern_semantics.rb, line 19 def record_module(name, path, body) @modules << ModuleBody.new(name, path, body) if body.is_a?(Prism::StatementsNode) end