AshIntrospection.ResourceInfo.Source (AshIntrospection v0.4.1)

Copy Markdown View Source

A %Ash.Info.Manifest{} with its lookup maps already built.

Ash.Info.Manifest.resource_lookup/1 and type_lookup/1 rebuild a map from a list on every call. AshIntrospection.ResourceInfo reads them dozens of times per request, so the maps are built once here and carried on the config map instead.

Callers pass either a bare %Ash.Info.Manifest{} or a prepared source under the :manifest config key; AshIntrospection.ResourceInfo.prepare/2 turns the first into the second. Preparing once and reusing the result is the supported shape — a bare manifest works and is O(resources) per read.

The source also carries the custom namespace AshIntrospection.Manifest.Decorator wrote under, so a read knows where to find decorated data. It defaults to AshIntrospection.Manifest.Custom.default_namespace/0.

Summary

Types

t()

A manifest plus the module-keyed lookups read from it.

Functions

Builds the lookup maps for manifest.

Types

t()

@type t() :: %AshIntrospection.ResourceInfo.Source{
  manifest: Ash.Info.Manifest.t(),
  namespace: atom(),
  resources: %{required(module()) => Ash.Info.Manifest.Resource.t()},
  types: %{required(module()) => Ash.Info.Manifest.Type.t()}
}

A manifest plus the module-keyed lookups read from it.

Functions

new(manifest, namespace \\ nil)

@spec new(Ash.Info.Manifest.t() | t(), atom() | nil) :: t()

Builds the lookup maps for manifest.

Returns an already prepared source unchanged, except that an explicit namespace replaces the one it carries.