AshBoundary.Declaration (ash_boundary v0.1.0)

Copy Markdown View Source

Installs a boundary declaration onto a module that is currently being compiled.

Summary

Types

t()

The definition map boundary stores in the persisted attribute.

Functions

Declares module as a boundary, as if it had called use Boundary. Must be called while module is still being compiled.

Returns true if module has been declared as a boundary.

Reads back the boundary definition installed on a compiled module, or nil.

Converts fully qualified export modules into the boundary-relative form.

Types

t()

@type t() :: %{
  opts: keyword(),
  pos: %{file: String.t() | nil, line: pos_integer() | nil},
  app: atom(),
  protocol?: boolean(),
  mix_task?: boolean()
}

The definition map boundary stores in the persisted attribute.

Functions

declare(module, opts)

@spec declare(
  module(),
  keyword()
) :: :ok

Declares module as a boundary, as if it had called use Boundary. Must be called while module is still being compiled.

  • :exports - fully qualified modules, converted to the relative form boundary expects.
  • :file / :line - source position for boundary's error messages.
  • Any other option passes through to boundary untouched.

Applies no defaults. Raises ArgumentError if an export lives outside the boundary's namespace.

declared?(module)

@spec declared?(module()) :: boolean()

Returns true if module has been declared as a boundary.

definition(module)

@spec definition(module()) :: t() | nil

Reads back the boundary definition installed on a compiled module, or nil.

relative_exports(boundary, exports)

@spec relative_exports(module(), [module()]) ::
  {:ok, [module()]} | {:error, [module()]}

Converts fully qualified export modules into the boundary-relative form.

Drops the boundary module itself. Returns {:error, modules} for modules outside boundary's namespace.