autoalias v0.2.0 Autoalias.Conflicts

Provides mechanism for resolving module conflicts

Link to this section Summary

Functions

Accepts list of modules and returns list of modules with resolved conflicts. Conflicts solving performs recursively till there will be no conflicts at all.

Link to this section Functions

Link to this function

resolve(modules)

Accepts list of modules and returns list of modules with resolved conflicts. Conflicts solving performs recursively till there will be no conflicts at all.

If we have several modules with the same ending and alias all of them, only last one will be accepted. For example if there is modules like Foo.Bar.SomeModule and Baz.Qux.Corge.SomeModule it will alias the longest module, and closest parent for all conflicted modules. In this case it will be:

alias Baz.Qux.Corge.SomeModule
alias Foo.Bar

So we can now use SomeModule to access first one and Bar.SomeModule for the second.

Here is the corner case when conflict appears with one-word module, e.g. SomeModule and MyApp.SomeModule. In this case it will create alias for MyApp.SomeModule and you will loose direct access to one-word SomeModule module. If this happened, you can prepend module with Elixir. prefix, like Elixir.SomeModule, to access it. Elixir module itself cannot be aliased at all.

This cases are pretty rare, but it can happen.