Ambient.Facade (Ambient v0.1.0)

Copy Markdown View Source

Re-export another module's public functions under the using module's name.

Handy for exposing an Ambient value under your own app's namespace without hand-writing – and having to maintain – a defdelegate list:

defmodule MyApp.Clock do
  use Ambient.Facade, for: Ambient.Clock
end

MyApp.Clock.set(~U[2026-01-01 00:00:00Z])   # delegates to Ambient.Clock

Delegates are derived from the target's public functions at compile time, so the facade never drifts when the target gains or loses a function.

Options

  • :for – the target module to re-export (required).
  • :only – restrict to these functions, as names (:set) or name/arity pairs ({:allow, 2}). When omitted, every public function is re-exported.
  • :except – functions to skip, in the same shape. Applied after :only.

Names beginning with __ are skipped – with one exception: __ambient_table__/0 is passed through when the target has it, so the facade can be handed to Ambient.start_servers/1 and Ambient.set_shared/2 in place of the value module it wraps. :only and :except don't apply to it.