Method: Hanami.loader

Defined in:
lib/hanami.rb

.loaderObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hanami.rb', line 18

def self.loader
  @loader ||= Zeitwerk::Loader.for_gem.tap do |loader|
    loader.inflector.inflect "db" => "DB"
    loader.inflector.inflect "db_logging" => "DBLogging"
    loader.inflector.inflect "slice_configured_db_operation" => "SliceConfiguredDBOperation"
    loader.inflector.inflect "sql_adapter" => "SQLAdapter"

    gem_lib = loader.dirs.first
    loader.ignore(
      "#{gem_lib}/hanami/{constants,boot,errors,extensions/router/errors,prepare,rake_tasks,setup}.rb",
      # Ignore conditionally-loaded classes dependent on gems that may not be included in the
      # user's Gemfile
      "#{gem_lib}/hanami/config/{assets,router,views}.rb",
      "#{gem_lib}/hanami/slice/router.rb",
      "#{gem_lib}/hanami/slice/routing/resolver.rb",
      "#{gem_lib}/hanami/slice/routing/middleware/stack.rb",
      "#{gem_lib}/hanami/extensions/**/*"
    )

    unless Hanami.bundled?("hanami-router")
      loader.ignore("#{gem_lib}/hanami/routes.rb")
    end
  end
end