<% if configuration.build_zeitwerk %> require "zeitwerk" <% if configuration.project_levels.positive? %> Zeitwerk::Loader.new.then do |loader| loader.tag = "<%= configuration.project_name %>" loader.push_dir "#{__dir__}<%= Array.new(configuration.project_levels, "/..").join %>" loader.setup end <% else %> Zeitwerk::Loader.new.then do |loader| loader.tag = File.basename __FILE__, ".rb" loader.push_dir __dir__ loader.setup end <% end %> <% end %> <% if configuration.build_zeitwerk %> <% namespace do %> <% if configuration.project_levels.positive? %> def self.loader registry = Zeitwerk::Registry @loader ||= registry.loaders.find { |loader| loader.tag == "<%= configuration.project_name %>" } end <% else %> def self.loader registry = Zeitwerk::Registry @loader ||= registry.loaders.find { |loader| loader.tag == File.basename(__FILE__, ".rb") } end <% end %> <% end %> <% else %> <% namespace %> <% end %>