Sha256: 73fa978da342d005138b16ab8d55109facc261964d2f4d56bb6b531cd22f2a93

Contents?: true

Size: 1.12 KB

Versions: 15

Compression:

Stored size: 1.12 KB

Contents

require "jets/bundle"
Jets::Bundle.setup
require "zeitwerk"

module Jets
  class Autoloaders
    require_relative "autoloaders/inflector"

    include Enumerable

    attr_reader :main, :once

    def initialize
      # This `require` delays loading the library on purpose.
      #
      # In Rails 7.0.0, railties/lib/rails.rb loaded Zeitwerk as a side-effect,
      # but a couple of edge cases related to Bundler and Bootsnap showed up.
      # They had to do with order of decoration of `Kernel#require`, something
      # the three of them do.
      #
      # Delaying this `require` up to this point is a convenient trade-off.
      require "zeitwerk"

      @main = Zeitwerk::Loader.new
      @main.tag = "jets.main"
      @main.inflector = Inflector

      @once = Zeitwerk::Loader.new
      @once.tag = "jets.once"
      @once.inflector = Inflector
    end

    def each
      yield main
      yield once
    end

    def logger=(logger)
      each { |loader| loader.logger = logger }
    end

    def log!
      each(&:log!)
    end

    def self.for_gem
      Gem.new.autoloader
    end
  end
end

require_relative "autoloaders/gem"

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/autoloaders.rb
jets-5.0.12 lib/jets/autoloaders.rb
jets-5.0.11 lib/jets/autoloaders.rb
jets-5.0.10 lib/jets/autoloaders.rb
jets-5.0.9 lib/jets/autoloaders.rb
jets-5.0.8 lib/jets/autoloaders.rb
jets-5.0.7 lib/jets/autoloaders.rb
jets-5.0.6 lib/jets/autoloaders.rb
jets-5.0.5 lib/jets/autoloaders.rb
jets-5.0.4 lib/jets/autoloaders.rb
jets-5.0.3 lib/jets/autoloaders.rb
jets-5.0.2 lib/jets/autoloaders.rb
jets-5.0.1 lib/jets/autoloaders.rb
jets-5.0.0 lib/jets/autoloaders.rb
jets-5.0.0.beta1 lib/jets/autoloaders.rb