Module: Reins::Autoloader

Defined in:
lib/reins/autoloader.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loaderObject (readonly)

Returns the value of attribute loader.



8
9
10
# File 'lib/reins/autoloader.rb', line 8

def loader
  @loader
end

Class Method Details

.eager_load!Object



19
20
21
# File 'lib/reins/autoloader.rb', line 19

def eager_load!
  @loader&.eager_load
end

.reload!Object



23
24
25
# File 'lib/reins/autoloader.rb', line 23

def reload!
  @loader&.reload
end

.reset!Object



27
28
29
30
# File 'lib/reins/autoloader.rb', line 27

def reset!
  @loader&.unload
  @loader = nil
end

.setup(paths) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/reins/autoloader.rb', line 10

def setup(paths)
  return if paths.empty?

  @loader = Zeitwerk::Loader.new
  paths.each { |p| @loader.push_dir(p) if Dir.exist?(p) }
  @loader.enable_reloading if Reins.config.reload_classes
  @loader.setup
end