MishkaGervaz.Form.Web.DataLoader.Helpers (MishkaGervaz v0.0.1-alpha.2)

Copy Markdown View Source

Shared helpers for MishkaGervaz.Form.Web.DataLoader.

Two reasons these live outside the __using__ macro:

  1. Reuse across the macro and user overrides. A user module that overrides load_record/3 (via use MishkaGervaz.Form.Web.DataLoader) can call any helper here without redefining it.
  2. Smaller compiled bytecode per consumer. Each use injects ~150 lines of pure-data helpers — extracting them means they compile once in this module rather than into every consumer's beam.

Three functional groups:

  • Field lookups & extraction (find_field/2, extract_existing_files/2, extract_dependency_values/2, extract_defaults_to_field_values/1) — pure reads off State / Phoenix.HTML.Form.
  • File normalization (normalize_file_list/1, normalize_file_info/1) — coerce upload payloads into %{filename: …} maps.
  • Coordination (load_dependent_relations/3, load_readonly_relation_options/3) — dispatch through a consumer-supplied function or module so defoverridable semantics are preserved.

See MishkaGervaz.Form.Web.DataLoader, MishkaGervaz.Form.Web.DataLoader.RecordLoader, MishkaGervaz.Form.Web.DataLoader.RelationLoader, MishkaGervaz.Form.Web.DataLoader.TenantResolver, MishkaGervaz.Form.Web.DataLoader.HookRunner, and MishkaGervaz.Form.Web.State.