# `Enact.Delegates`
[🔗](https://github.com/svycal/enact/blob/v0.1.0/lib/enact/delegates.ex#L1)

Opt-in helper that generates context one-liners for `Enact.run/3`,
`Enact.dry_run/3`, `Enact.subject/3`, and `Enact.authorized/3`.

Phoenix contexts remain the application API; this only writes the
forwarding functions hosts otherwise type by hand. It is not an
action-definition DSL — actions stay ordinary modules, and handwritten
delegates remain valid.

    defmodule MyApp.Contacts do
      alias MyApp.Contacts.Actions.{CreateContact, UpdateContact}

      use Enact.Delegates, actions: [CreateContact, UpdateContact]

      # reads and load_subject fetchers stay here
    end

For each action `MyApp.Contacts.Actions.CreateContact`, this defines:

    def create_contact(params, opts),
      do: Enact.run(CreateContact, params, opts)

    def create_contact_dry_run(params, opts),
      do: Enact.dry_run(CreateContact, params, opts)

    def create_contact_subject(params, opts),
      do: Enact.subject(CreateContact, params, opts)

    def create_contact_authorized(params, opts),
      do: Enact.authorized(CreateContact, params, opts)

Names come from the last segment of the module, underscored via
`Macro.underscore/1`. All four wrappers are generated for every listed
action. Bodies only forward — no param reshaping, no persistable fields
stamped in.

If a host wants a different public name or a non-forwarding body, omit
that module from the list and write the function by hand.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
