AshLua.Runtime (ash_lua v0.1.0)

Copy Markdown View Source

Builds a Lua VM with Ash action bindings derived from Ash.Info.Manifest.generate/1 and dispatches calls through to Ash with consistent actor / tenant / context plumbing.

Lua surface

local user, err = accounts.user.create({ name = "Zach" })
assert(accounts.todo.complete({ id = todo.id }))      -- raises on error

Action callables always return (result, nil) on success and (nil, err_table) on failure; wrap a call in assert() for raise semantics.

Actor, tenant, and context are host-supplied via the eval opts and are never reflected to or mutable from the script.

Summary

Functions

Builds a %Lua{} VM with Ash bindings installed.

Evaluates a Lua script string against a VM built from opts.

Functions

build(opts)

@spec build(keyword()) :: Lua.t()

Builds a %Lua{} VM with Ash bindings installed.

Options

  • :otp_app (required) — passed through to Ash.Info.Manifest.generate/1.
  • :actor, :tenant, :context — host-supplied; merged into every Ash call.
  • :manifest — pre-built %Ash.Info.Manifest{} (skips regeneration).
  • :lua — pre-built %Lua{} to install bindings on. Defaults to Lua.new/0.

eval!(script, opts)

@spec eval!(
  String.t(),
  keyword()
) :: {list(), Lua.t()}

Evaluates a Lua script string against a VM built from opts.

Returns {results, lua} like Lua.eval!/2.