Skip to content

Commit

Permalink
Update exported_by_child_subboundary? to include :all subdomains
Browse files Browse the repository at this point in the history
  • Loading branch information
Nezteb committed Sep 25, 2024
1 parent 7cb6d4a commit 9b44997
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
14 changes: 8 additions & 6 deletions lib/boundary/checker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,14 @@ defmodule Boundary.Checker do
|> Stream.take_while(&(not is_nil(&1)))
|> Enum.find(&(Enum.at(&1.ancestors, 0) == boundary.name))
|> case do
nil -> false
child_subboundary -> export in [child_subboundary.name | child_subboundary.exports]
nil ->
false

%{exports: [{_, []}]} = child_subboundary ->
String.starts_with?(to_string(export), to_string(child_subboundary.name))

child_subboundary ->
export in [child_subboundary.name | child_subboundary.exports]
end
end
end
Expand Down Expand Up @@ -331,10 +337,6 @@ defmodule Boundary.Checker do

defp export_matches?(_view, _boundary, module, module), do: true

defp export_matches?(_view, _boundary, {root, []}, module) do
String.starts_with?(to_string(module), to_string(root))
end

defp export_matches?(view, boundary, {root, opts}, module) do
String.starts_with?(to_string(module), to_string(root)) and
not Enum.any?(Keyword.get(opts, :except, []), &(Module.concat(root, &1) == module)) and
Expand Down
15 changes: 9 additions & 6 deletions test/mix/tasks/compile/boundary_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,14 +1154,16 @@ defmodule Mix.Tasks.Compile.BoundaryTest do
defmodule Schemas.Foo do def fun(), do: :ok end
defmodule Schemas.Bar do def fun(), do: :ok end
end
defmodule #{module1}.Subdomain do
use Boundary, exports: :all
end
defmodule Subdomain do
use Boundary, exports: :all
defmodule #{module1}.Subdomain.Module do
def fun(), do: :ok
def fun(), do: :ok
defmodule Module do
def fun(), do: :ok
end
end
end
defmodule #{module2} do
Expand All @@ -1171,6 +1173,7 @@ 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()
end
end
Expand Down

0 comments on commit 9b44997

Please # to comment.