Class: AnnotateRb::EagerLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/annotate_rb/eager_loader.rb

Overview

Not sure what this does just yet

Class Method Summary collapse

Class Method Details

.call(options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/annotate_rb/eager_loader.rb', line 7

def call(options)
  options[:require].count > 0 && options[:require].each { |path| require path }

  if defined?(::Rails::Application)
    if defined?(::Zeitwerk)
      # Delegate to Zeitwerk to load stuff as needed
    else
      klass = ::Rails::Application.send(:subclasses).first
      klass.eager_load!
    end
  else
    options[:model_dir].each do |dir|
      ::Rake::FileList["#{dir}/**/*.rb"].each do |fname|
        require File.expand_path(fname)
      end
    end
  end
end