Flicker.FacetEditor.Switch (Flicker v0.1.0)

Copy Markdown View Source

The boolean editor (Spec 019) — and the one editor with no pop-out.

A flick is a complete value, so there is nothing for a modal surface to protect: it commits on toggle, inline (ADR-011). Atomic commit still applies — this is the degenerate case where "atomic" and "one interaction" coincide.

"Filtered false" and "not filtered at all" stay distinct: the switch expresses the first, and the pill's remove control the second. That is why there is no third position here.

Summary

Functions

Any boolean is complete; nil (nothing chosen yet) is not.

Parses either literal, case-insensitively — matching the parser rather than being stricter than it.

"true" or "false" — the same literals the grammar accepts.

Functions

complete?(value, facet)

@spec complete?(term(), Flicker.Facet.t()) :: boolean()

Any boolean is complete; nil (nothing chosen yet) is not.

Examples

iex> Flicker.FacetEditor.Switch.complete?(false, %Flicker.Facet{key: :v})
true

iex> Flicker.FacetEditor.Switch.complete?(nil, %Flicker.Facet{key: :v})
false

parse(text, facet)

@spec parse(String.t(), Flicker.Facet.t()) :: {:ok, boolean()} | :error

Parses either literal, case-insensitively — matching the parser rather than being stricter than it.

Examples

iex> Flicker.FacetEditor.Switch.parse("TRUE", %Flicker.Facet{key: :verified?})
{:ok, true}

iex> Flicker.FacetEditor.Switch.parse("maybe", %Flicker.Facet{key: :verified?})
:error

serialise(value, facet)

@spec serialise(boolean(), Flicker.Facet.t()) :: String.t()

"true" or "false" — the same literals the grammar accepts.

Examples

iex> Flicker.FacetEditor.Switch.serialise(true, %Flicker.Facet{key: :verified?})
"true"