Spectre.Governance.ChangeSet.Registry (Spectre v0.3.0)

Copy Markdown View Source

Host-owned registry mapping inert ChangeSet operation types to reviewed code.

Registration accepts modules, never runtime data. This keeps the vocabulary extensible without a central dispatch case and without permitting a ChangeSet to choose an arbitrary handler.

Summary

Functions

Applies operations in order through their registered handlers.

Returns the reviewed built-in governance vocabulary.

Builds a registry from compiled handler modules.

Builds a registry or raises with the stable validation reason.

Registers one loaded reviewed handler.

Types

entry()

@type entry() :: %{handler: module(), component_classes: [atom()]}

t()

@type t() :: %Spectre.Governance.ChangeSet.Registry{
  entries: %{optional(String.t()) => entry()}
}

Functions

apply(registry, operations, composition, context)

Applies operations in order through their registered handlers.

default()

@spec default() :: t()

Returns the reviewed built-in governance vocabulary.

new(handlers)

@spec new([module()]) :: {:ok, t()} | {:error, term()}

Builds a registry from compiled handler modules.

new!(handlers)

@spec new!([module()]) :: t()

Builds a registry or raises with the stable validation reason.

register(registry, handler)

@spec register(t(), module()) :: {:ok, t()} | {:error, term()}

Registers one loaded reviewed handler.