AshLua.Type behaviour (ash_lua v0.1.0)

Copy Markdown View Source

Extends an Ash type with Lua-facing metadata.

Add use AshLua.Type to a custom type module (typically alongside use Ash.Type or use Ash.Type.NewType) and implement type_name/0 to control the name surfaced in generated documentation (AshLua.Docs) for that type.

defmodule MyApp.Slug do
  use Ash.Type.NewType, subtype_of: :string
  use AshLua.Type

  @impl AshLua.Type
  def type_name, do: "slug"
end

When a module does not implement type_name/0, the default name is derived from the module itself: the last module segment, with Ash.Type. prefixed modules underscored (Ash.Type.UUID"uuid", Ash.Type.Boolean"boolean").

Summary

Functions

Returns the Lua-facing type name for the given module.

Callbacks

type_name()

(optional)
@callback type_name() :: String.t()

Functions

type_name(module)

@spec type_name(module()) :: String.t()

Returns the Lua-facing type name for the given module.

Uses the module's type_name/0 callback when defined, otherwise derives a name from the module itself.