AshBoundary (ash_boundary v0.1.0)

Copy Markdown View Source

Declares a boundary for an Ash.Domain.

AshBoundary derives the boundary declaration from the domain DSL:

defmodule MyApp.Blog do
  use Ash.Domain, extensions: [AshBoundary]

  boundary do
    deps [MyApp.Accounts]
    exports [MyApp.Blog.PostStatus]
  end

  resources do
    resource MyApp.Blog.Post do
      define :get_post, action: :read
      define :update_post, action: :update
    end

    resource MyApp.Blog.Comment do
      # no domain-level define, so it stays internal
    end
  end
end

This is the same declaration use Boundary, deps: [...], exports: [...] would install by hand. Every option in the boundary section passes straight through to boundary, unchanged: see Boundary's own documentation for what deps, exports, check, type and dirty_xrefs do and what boundary checks by default. AshBoundary adds one thing on top: exports is computed to include the domain module itself and every resource with at least one domain-level define, in addition to whatever the exports option names.

Setup

Add the :boundary compiler to your project configuration:

def project do
  [
    app: :my_app,
    compilers: [:boundary] ++ Mix.compilers(),
    # ...
  ]
end

What gets exported

  • The domain module is public.
  • Each resource that exposes a code interface in the domain is public.
  • Each module named in exports is public.
  • All other modules in the domain's namespace are internal.
  • Referencing another domain requires an explicit boundary dep, subject to whatever check that domain declares.

Summary

Functions

boundary(body)

(macro)