Class: Dry::Rails::AutoRegistrars::App Private

Inherits:
System::AutoRegistrar
  • Object
show all
Defined in:
lib/dry/rails/auto_registrars/app.rb

Overview

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

This is the default auto-registrar configured in the Container

Instance Method Summary collapse

Instance Method Details

#relative_path(dir, file_path) ⇒ Object

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.

Resolve a path relative to the system root

This works just like in ‘dry-system` except that it’s app-dir aware. This means it will turn ‘app/operations/foo/bar` to `foo/bar` because app dirs are treated as root dirs.

In a typical dry-system setup ‘app` would be the root and everything inside this path would indicate the constant hierachy, so `app/operations/foo/bar` => `Operations/Foo/Bar` but *this is not the Rails convention* so we need this special auto-registrar.



22
23
24
25
26
27
# File 'lib/dry/rails/auto_registrars/app.rb', line 22

def relative_path(dir, file_path)
  path = super
  return path unless dir.start_with?("app")

  path.split("/")[1..-1].join("/")
end