PhoenixFlags.Entry (PhoenixFlags v0.9.0)

Copy Markdown View Source

Ecto schema for a system configuration entry.

All values are stored as strings and cast to their native type on cache load.

Supported Types

TypeStored asCast toValidation
string"hello""hello"none
boolean"true"truemust be "true" or "false"
integer"42"42must parse as integer
decimal"3000"Decimal.new("3000")must parse as decimal
percentage"50"Decimal.new("50")0..100
select"ses""ses"must be a declared option
secretciphertextdecrypted plaintextnone (encrypted at rest)
variant"a=50,b=50"%Variant{}weights total 100, declared

A variant entry holds a split, not a single value, and is read with variant/2 rather than get/2. See PhoenixFlags.Variant.

Summary

Functions

Casts a stored string value to its native Elixir type.

Changeset for updating an entry's value. Only :value is writable.

Functions

cast_value(value, type)

Casts a stored string value to its native Elixir type.

changeset(entry, attrs, opts \\ [])

Changeset for updating an entry's value. Only :value is writable.

:secret entries accept "" as a way to clear the stored value; for every other type, "" is still treated as missing.

Options

  • :select_options — the {label, value} tuples declared for a :select flag. When given, the new value must be one of them. Callers that do not have the declaration at hand (e.g. building an empty form) can omit it, in which case no membership check runs.
  • :variants — the declared variant names for a :variant flag. When given, every name in the submitted weights must be one of them. Same omission rule as :select_options.