Wraith.Settings (Wraith v0.1.0)

View Source

The site: one item, read on every public page. get/0 returns the defaults merged with what was saved, so a fresh table is a working site.

Reads come from Wraith.Settings.Cache; every write goes through write/1 so the cache is refreshed on this node and, over PubSub, on the others. Code that writes the site item directly (bypassing this module) must call Wraith.Settings.Cache.invalidate/0 afterwards.

Summary

Functions

Flip the setup flag once the owner exists.

A secret in the clear (for the code that needs it), or nil.

Is the secret set? (Its hint, e.g. sk_…abcd, for the UI.)

Save the editable fields; unknown keys are dropped, bad values refused.

Change the site item with fun (current item or nil → new item) and refresh the cache. The one write path for the site item; update/1 is the validated, allowlisted front of it, this is for internal state other contexts keep on the item (the studio's key, the setup flag).

Functions

defaults()

get()

@spec get() :: map()

mark_setup_done()

Flip the setup flag once the owner exists.

secret(name)

@spec secret(String.t()) :: String.t() | nil

A secret in the clear (for the code that needs it), or nil.

secret_fields()

secret_hint(name)

Is the secret set? (Its hint, e.g. sk_…abcd, for the UI.)

setup_done?()

update(attrs)

@spec update(map()) :: {:ok, map()} | {:error, map()}

Save the editable fields; unknown keys are dropped, bad values refused.

write(fun)

@spec write((map() | nil -> map())) :: {:ok, map()} | {:error, term()}

Change the site item with fun (current item or nil → new item) and refresh the cache. The one write path for the site item; update/1 is the validated, allowlisted front of it, this is for internal state other contexts keep on the item (the studio's key, the setup flag).