Class: RailsAiContext::Introspectors::AutoloadIntrospector

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai_context/introspectors/autoload_introspector.rb

Overview

Extracts the autoloading configuration: Zeitwerk vs Classic, custom inflections, autoload/eager-load paths, collapsed dirs, and ignored paths. Covers RAILS_NERVOUS_SYSTEM.md §3 (Autoloading — Zeitwerk).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ AutoloadIntrospector

Returns a new instance of AutoloadIntrospector.



11
12
13
# File 'lib/rails_ai_context/introspectors/autoload_introspector.rb', line 11

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



9
10
11
# File 'lib/rails_ai_context/introspectors/autoload_introspector.rb', line 9

def app
  @app
end

Instance Method Details

#callHash

Returns autoloader configuration.

Returns:

  • (Hash)

    autoloader configuration



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rails_ai_context/introspectors/autoload_introspector.rb', line 16

def call
  {
    mode: detect_mode,
    zeitwerk_available: zeitwerk_available?,
    autoloaders: extract_autoloaders,
    autoload_paths: relativize(app.config.autoload_paths),
    autoload_once_paths: relativize(app.config.autoload_once_paths),
    eager_load_paths: relativize(app.config.eager_load_paths),
    eager_load: !!app.config.eager_load,
    custom_inflections: extract_custom_inflections
  }
rescue => e
  $stderr.puts "[rails-ai-context] AutoloadIntrospector#call failed: #{e.message}" if ENV["DEBUG"]
  { error: e.message }
end