Module: ActiveSupport::Dependencies::ZeitwerkIntegration::Decorations

Defined in:
activesupport/lib/active_support/dependencies/zeitwerk_integration.rb

Instance Method Summary collapse

Instance Method Details

#autoloaded?(object) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
# File 'activesupport/lib/active_support/dependencies/zeitwerk_integration.rb', line 30

def autoloaded?(object)
  cpath = object.is_a?(Module) ? real_mod_name(object) : object.to_s
  Rails.autoloaders.main.unloadable_cpath?(cpath)
end

#autoloaded_constantsObject



26
27
28
# File 'activesupport/lib/active_support/dependencies/zeitwerk_integration.rb', line 26

def autoloaded_constants
  Rails.autoloaders.main.unloadable_cpaths
end

#clearObject



10
11
12
13
14
15
16
# File 'activesupport/lib/active_support/dependencies/zeitwerk_integration.rb', line 10

def clear
  Dependencies.unload_interlock do
    Rails.autoloaders.main.reload
  rescue Zeitwerk::ReloadingDisabledError
    raise "reloading is disabled because config.cache_classes is true"
  end
end

#constantize(cpath) ⇒ Object



18
19
20
# File 'activesupport/lib/active_support/dependencies/zeitwerk_integration.rb', line 18

def constantize(cpath)
  ActiveSupport::Inflector.constantize(cpath)
end

#safe_constantize(cpath) ⇒ Object



22
23
24
# File 'activesupport/lib/active_support/dependencies/zeitwerk_integration.rb', line 22

def safe_constantize(cpath)
  ActiveSupport::Inflector.safe_constantize(cpath)
end

#unhook!Object



40
41
42
# File 'activesupport/lib/active_support/dependencies/zeitwerk_integration.rb', line 40

def unhook!
  :no_op
end

#verbose=(verbose) ⇒ Object



35
36
37
38
# File 'activesupport/lib/active_support/dependencies/zeitwerk_integration.rb', line 35

def verbose=(verbose)
  l = verbose ? logger || Rails.logger : nil
  Rails.autoloaders.each { |autoloader| autoloader.logger = l }
end