Skip to content

Commit

Permalink
Cleanup; add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nezteb committed Sep 25, 2024
1 parent 9b44997 commit db8693e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lib/boundary.ex
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ defmodule Boundary do
export all of these modules with the `exports: [{Schemas, except: [Base]}, ...]`. This will
export all `MySystem.Schemas.*` modules, except for `MySystem.Schemas.Base`.
You can also export all modules of the boundary with `use Boundary, exports: :all`. To exclude
some modules from the export list use, `use Boundary, exports: {:all, except: [SomeMod, ...]}`.
You can also export all modules of the boundary with `use Boundary, exports: :all`. This will also
export all sub-modules of the boundary. To exclude some modules from the export list use,
`use Boundary, exports: {:all, except: [SomeMod, ...]}`.
Mass export is not advised in most situations. Prefer explicitly listing exported modules. If
your export list is long, it's a possible indication of an overly fragmented interface. Consider
Expand Down
5 changes: 3 additions & 2 deletions lib/boundary/checker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ defmodule Boundary.Checker do
nil ->
false

%{exports: [{_, []}]} = child_subboundary ->
String.starts_with?(to_string(export), to_string(child_subboundary.name))
# If the export's `owner_boundary` exports all modules, include sub-modules
%{exports: [{export_module, []}]} ->
String.starts_with?(to_string(export), to_string(export_module))

child_subboundary ->
export in [child_subboundary.name | child_subboundary.exports]
Expand Down
13 changes: 9 additions & 4 deletions test/mix/tasks/compile/boundary_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,21 +1147,25 @@ defmodule Mix.Tasks.Compile.BoundaryTest do
module1 = unique_module_name()
module2 = unique_module_name()

module_test "exporting all modules and submodules",
module_test "exporting all modules and sub-modules",
"""
defmodule #{module1} do
use Boundary, exports: :all
defmodule Schemas.Foo do def fun(), do: :ok end
defmodule Schemas.Bar do def fun(), do: :ok end
defmodule Subdomain do
defmodule SubModule do
use Boundary, exports: :all
def fun(), do: :ok
defmodule Module do
def fun(), do: :ok
defmodule Another do
def fun(), do: :ok
end
end
end
end
Expand All @@ -1173,8 +1177,9 @@ defmodule Mix.Tasks.Compile.BoundaryTest do
#{module1}.Schemas.Foo.fun()
#{module1}.Schemas.Bar.fun()
#{module1}.Schemas.Base.fun()
#{module1}.Subdomain.fun()
#{module1}.Subdomain.Module.fun()
#{module1}.SubModule.fun()
#{module1}.SubModule.Module.fun()
#{module1}.SubModule.Module.Another.fun()
end
end
""" do
Expand Down

0 comments on commit db8693e

Please # to comment.