GreenAsh.Registry (GreenAsh v0.1.1)

Copy Markdown View Source

Runtime discovery of Ash resources / actions from the list of domains provided by the host (via the router macro), and module <-> slug / primary key resolution for the console's routes.

No resource is hardcoded: everything comes from the domains passed as an argument and from Ash introspection.

Summary

Functions

Action struct by name (string or atom).

Label of an action: its description if defined, otherwise its humanized name.

Actions of a resource.

Decodes a primary key token into an identifier usable by Ash.get/2.

Encodes a record's primary key into a token for URL/form use.

Resource matching a slug among domains, or nil.

Short label of a resource (last segment of the module).

URL slug of a resource (e.g.: MyApp.Bank.Account -> "account").

Human description of a resource, if defined, otherwise its label.

All resources exposed by domains.

Functions

action(resource, name)

Action struct by name (string or atom).

action_label(action)

Label of an action: its description if defined, otherwise its humanized name.

actions(resource)

Actions of a resource.

decode_pk(resource, token)

Decodes a primary key token into an identifier usable by Ash.get/2.

encode_pk(record)

Encodes a record's primary key into a token for URL/form use.

Simple PK -> the raw value (backward-compatible). Composite PK -> a base64url token of a JSON {field => value}.

resource_by_slug(domains, slug)

Resource matching a slug among domains, or nil.

resource_label(resource)

Short label of a resource (last segment of the module).

resource_slug(resource)

URL slug of a resource (e.g.: MyApp.Bank.Account -> "account").

resource_title(resource)

Human description of a resource, if defined, otherwise its label.

resources(domains)

All resources exposed by domains.