Jido.Character.Definition (Jido Character v1.0.0)

Copy Markdown View Source

Definition of a character type, used by use Jido.Character.

Stores compile-time configuration for character modules:

  • module - The module that defined this character type
  • extensions - List of enabled extensions (atoms)
  • defaults - Default attribute values for new characters
  • adapter - Persistence adapter module
  • adapter_opts - Options passed to the persistence adapter
  • renderer - Renderer module implementing Jido.Character.Renderer behaviour
  • renderer_opts - Options passed to the renderer

Summary

Functions

Creates a new Definition struct from a map, validating with Zoi schema.

Creates a new Definition struct from a map, raising on validation errors.

Returns the Zoi schema for Definition

Types

t()

@type t() :: %Jido.Character.Definition{
  adapter: atom(),
  adapter_opts: [any()],
  defaults: map(),
  extensions: [atom()],
  module: atom(),
  renderer: atom(),
  renderer_opts: [any()]
}

Functions

new(attrs)

@spec new(map()) :: {:ok, t()} | {:error, term()}

Creates a new Definition struct from a map, validating with Zoi schema.

Examples

iex> Jido.Character.Definition.new(%{module: MyApp.Character})
{:ok, %Jido.Character.Definition{module: MyApp.Character, extensions: [], ...}}

iex> Jido.Character.Definition.new(%{})
{:error, _validation_errors}

new!(attrs)

@spec new!(map()) :: t()

Creates a new Definition struct from a map, raising on validation errors.

Examples

iex> Jido.Character.Definition.new!(%{module: MyApp.Character})
%Jido.Character.Definition{module: MyApp.Character, extensions: [], ...}

schema()

Returns the Zoi schema for Definition