Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion lib/permit/actions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Loading