MishkaGervaz.Form.Entities.Access (MishkaGervaz v0.0.1-alpha.2)

Copy Markdown View Source

Per-mode (or global) access gate inside the source block.

access declarations live alongside actor_key and master_check inside MishkaGervaz.Form.Dsl.Source. Each entry decides whether a given form mode (:create or :update) is reachable for the current user.

Three calling styles are supported:

# Style A — per-mode with keyword opts
access :create, restricted: true

# Style B — per-mode with condition function
access :create, fn state -> state.master_user? end

# Style C — global gate (`fn mode, state -> bool` in the mode slot)
access fn mode, state -> mode == :update or state.master_user? end

Style C is the catch-all: it runs for every mode and is useful when you want one rule covering both :create and :update.

See MishkaGervaz.Form.Dsl.Source for the surrounding section.

Summary

Types

t()

@type t() :: %MishkaGervaz.Form.Entities.Access{
  __identifier__: term(),
  __spark_metadata__: map() | nil,
  condition: (map() -> boolean()) | (atom(), map() -> boolean()) | nil,
  mode: :create | :update | (atom(), map() -> boolean()),
  restricted: boolean()
}

Functions

transform(access)