Class: Zeitwerk::GemLoader

Inherits:
Loader
  • Object
show all
Includes:
RealModName
Defined in:
lib/zeitwerk/gem_loader.rb

Instance Attribute Summary

Attributes inherited from Loader

#autoloaded_dirs, #autoloads, #namespace_dirs, #shadowed_files, #to_unload

Attributes included from Loader::Config

#inflector, #logger, #roots

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RealModName

#real_mod_name

Methods inherited from Loader

all_dirs, #cpath_expected_at, eager_load_all, eager_load_namespace, for_gem, for_gem_extension, #reload, #unload, #unloadable_cpath?, #unloadable_cpaths, #unregister

Methods included from Internal

#internal

Methods included from Loader::EagerLoad

#eager_load, #eager_load_dir, #eager_load_namespace, #load_file

Methods included from Loader::Config

#collapse, #dirs, #do_not_eager_load, #enable_reloading, #ignore, #log!, #on_load, #on_setup, #on_unload, #push_dir, #reloading_enabled?, #tag, #tag=

Methods included from Loader::Callbacks

#on_dir_autoloaded, #on_file_autoloaded, #on_namespace_loaded

Constructor Details

#initialize(root_file, namespace:, warn_on_extra_files:) ⇒ GemLoader

Returns a new instance of GemLoader.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/zeitwerk/gem_loader.rb', line 19

def initialize(root_file, namespace:, warn_on_extra_files:)
  super()

  @tag = File.basename(root_file, ".rb")
  @tag = real_mod_name(namespace) + "-" + @tag unless namespace.equal?(Object)

  @inflector           = GemInflector.new(root_file)
  @root_file           = File.expand_path(root_file)
  @root_dir            = File.dirname(root_file)
  @warn_on_extra_files = warn_on_extra_files

  push_dir(@root_dir, namespace: namespace)
end

Class Method Details

.__new(root_file, namespace:, warn_on_extra_files:) ⇒ Object



14
15
16
# File 'lib/zeitwerk/gem_loader.rb', line 14

def self.__new(root_file, namespace:, warn_on_extra_files:)
  new(root_file, namespace: namespace, warn_on_extra_files: warn_on_extra_files)
end

Instance Method Details

#setupObject



34
35
36
37
# File 'lib/zeitwerk/gem_loader.rb', line 34

def setup
  warn_on_extra_files if @warn_on_extra_files
  super
end