# `Clarity.Perspective.Lensmaker`
[🔗](https://github.com/team-alembic/clarity/blob/v0.5.1/lib/clarity/perspective/lensmaker.ex#L1)

Behavior for modules that create and update lenses.

Lensmakers are plugins that can create new lenses or enhance existing ones created
by other lensmakers. This allows for a composable system where extensions can
add functionality to base lenses.

## Example

    defmodule MyApp.SecurityLensmaker do
      @behaviour Clarity.Perspective.Lensmaker

      alias Clarity.Graph.Filter
      alias Clarity.Perspective.Lens

      @impl Clarity.Perspective.Lensmaker
      def make_lens do
        %Lens{
          id: "security",
          name: "Security Audit",
          description: "Focus on security-related vertices",
          icon: fn -> ~H"🛡️" end,
          filter: Filter.vertex_type([Auth.Module, Permission.Module])
        }
      end
    end

## Extension Example

    defmodule MyApp.SecurityReportExtension do
      @behaviour Clarity.Perspective.Lensmaker

      @impl Clarity.Perspective.Lensmaker
      def update_lens(%{id: "security"} = lens) do
        # Example: Could modify the lens's content sorter or other properties
        lens
      end

      def update_lens(lens), do: lens
    end

## Configuration

Register lensmakers in your application configuration:

    config :my_app, :clarity_perspective_lensmakers, [
      MyApp.SecurityLensmaker,
      MyApp.SecurityReportExtension
    ]

## Two-Phase Lens Creation

1. **Creation Phase**: Calls `make_lens/0` on lensmakers that implement it
2. **Enhancement Phase**: Calls `update_lens/1` on all lensmakers for each lens

This allows extensions to enhance base lenses created by other modules.

# `result`

```elixir
@type result(type) :: {:ok, type} | {:error, term()}
```

# `t`

```elixir
@type t() :: module()
```

# `make_lens`
*optional* 

```elixir
@callback make_lens() :: Clarity.Perspective.Lens.t()
```

Creates a new lens.

# `update_lens`
*optional* 

```elixir
@callback update_lens(lens :: Clarity.Perspective.Lens.t()) ::
  Clarity.Perspective.Lens.t()
```

Updates an existing lens, potentially enhancing it with additional functionality.

Extensions typically check the lens ID and only modify lenses they are designed to enhance.

---

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