Class: RailsAiContext::Introspectors::AutoloadIntrospector

Inherits:
Object
  • Object
show all
Extended by:
StaticTier
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).

Constant Summary collapse

INFLECTION_DIRECTIVES =
%i[acronym plural singular irregular uncountable human].freeze

Constants included from StaticTier

StaticTier::ALTERNATE_SOURCE, StaticTier::FILES_ONLY, StaticTier::KINDS, StaticTier::RUNTIME_ONLY

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StaticTier

answers_statically?, static_tier, static_tier_declared?, unavailable_reason, validate_static_tier!

Constructor Details

#initialize(app) ⇒ AutoloadIntrospector

Returns a new instance of AutoloadIntrospector.



16
17
18
# File 'lib/rails_ai_context/introspectors/autoload_introspector.rb', line 16

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



14
15
16
# File 'lib/rails_ai_context/introspectors/autoload_introspector.rb', line 14

def app
  @app
end

Instance Method Details

#callHash

Returns autoloader configuration.

Returns:

  • (Hash)

    autoloader configuration



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rails_ai_context/introspectors/autoload_introspector.rb', line 21

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