# `Lotus.Web.Actor`
[🔗](https://github.com/elixir-lotus/lotus_web/blob/v1.2.0/lib/lotus/web/actor.ex#L1)

Who the dashboard is acting for, in the shape Lotus core expects.

Core accepts `:context` and `:scope` on every call that runs a query or
lists schema objects. `:context` reaches middleware and telemetry, `:scope`
reaches the visibility resolver and the cache key. The dashboard resolves
both at mount through `Lotus.Web.Resolver` and carries them as assigns;
this module turns those assigns into the option list core takes.

A `nil` context and a `nil` scope produce `[]`, so an unscoped dashboard
calls core exactly as it did before an actor existed — same middleware
payloads, same cache keys.

## Catching an actor that never arrived

A `Phoenix.LiveComponent` holds only what its parent passes, so a component
nobody handed the actor to calls core unscoped, and silently. Set

    config :lotus_web, strict_actor: true

in `dev` and `test` and `opts/1` raises for assigns that carry no `:context`
key at all, which tells that mistake apart from a dashboard that has no actor
to give. Leave it off in production, where an unscoped call beats a crash.

# `t`

```elixir
@type t() :: {term(), term()}
```

The actor as the dashboard carries it between components: `{context, scope}`.

# `merge`

```elixir
@spec merge(keyword(), map() | t()) :: keyword()
```

Merge the actor options into an existing option list.

Options already present win, so a caller can override the actor for a
single call.

# `opts`

```elixir
@spec opts(map() | t()) :: keyword()
```

Build the `:context` / `:scope` options for a core call.

Takes either the socket assigns or an explicit `{context, scope}` pair.
Keys whose value is `nil` are left out.

# `resolve`

```elixir
@spec resolve(module() | nil, Lotus.Web.Resolver.user()) :: {term(), term()}
```

Resolve the actor for a user through the given resolver.

Returns `{context, scope}`. Both are `nil` unless the resolver implements
`c:Lotus.Web.Resolver.resolve_context/1` or
`c:Lotus.Web.Resolver.resolve_scope/1`.

---

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