From 1acaf6ef2a57ccf43ba02f45198da764fe399476 Mon Sep 17 00:00:00 2001 From: Dawid Sawczuk Date: Thu, 16 Apr 2026 10:13:52 +0200 Subject: [PATCH] feat: add plural_actions/0 callback to Permit.Actions --- CHANGELOG.md | 4 ++++ lib/permit/actions.ex | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7c97c1..138309d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +- `plural_actions/0` callback on `Permit.Actions`, mirroring `singular_actions/0`. Defaults to `[]`. Used by `Permit.Phoenix.Actions` to exclude collection style actions (e.g. `:list`, `:search`, `:feed`) from router based promotion to singular. + ## [v0.3.3] ### Fixed diff --git a/lib/permit/actions.ex b/lib/permit/actions.ex index 6e7f924..ebc6a14 100644 --- a/lib/permit/actions.ex +++ b/lib/permit/actions.ex @@ -100,6 +100,15 @@ defmodule Permit.Actions do """ @callback singular_actions() :: [Types.action_group()] + @doc ~S""" + Declares which actions are explicitly plural, overriding any heuristic that + would otherwise classify them as singular. + + Useful for collection-style actions whose names or routes would otherwise be + misclassified, e.g. `:list`, `:search`, `:feed`. + """ + @callback plural_actions() :: [Types.action_group()] + defmacro __using__(_opts) do quote do @behaviour Actions @@ -129,8 +138,12 @@ defmodule Permit.Actions do @impl Actions def singular_actions, do: crud_singular() + @impl Actions + def plural_actions, do: [] + defoverridable grouping_schema: 0, - singular_actions: 0 + singular_actions: 0, + plural_actions: 0 end end