mirror of
https://github.com/ash-project/ash.git
synced 2024-09-19 13:03:02 +12:00
improvement: ArgumentError for non-existent actions in Ash.can?
This commit is contained in:
parent
d6a973cef0
commit
24cc008410
1 changed files with 25 additions and 7 deletions
|
@ -132,32 +132,50 @@ defmodule Ash.Can do
|
||||||
defp resource_subject_input(action_or_query_or_changeset, domain, actor, opts) do
|
defp resource_subject_input(action_or_query_or_changeset, domain, actor, opts) do
|
||||||
case action_or_query_or_changeset do
|
case action_or_query_or_changeset do
|
||||||
{resource, name} when is_atom(name) and is_atom(resource) ->
|
{resource, name} when is_atom(name) and is_atom(resource) ->
|
||||||
|
action =
|
||||||
|
Ash.Resource.Info.action(resource, name) ||
|
||||||
|
raise ArgumentError, "No such action #{name} on #{inspect(resource)}"
|
||||||
|
|
||||||
resource_subject_input(
|
resource_subject_input(
|
||||||
{resource, Ash.Resource.Info.action(resource, name), %{}},
|
{resource, action, %{}},
|
||||||
domain,
|
domain,
|
||||||
actor,
|
actor,
|
||||||
opts
|
opts
|
||||||
)
|
)
|
||||||
|
|
||||||
{resource, name, input} when is_atom(name) and is_atom(resource) ->
|
{resource, name, input} when is_atom(name) and is_atom(resource) and not is_nil(name) ->
|
||||||
|
action =
|
||||||
|
Ash.Resource.Info.action(resource, name) ||
|
||||||
|
raise ArgumentError, "No such action #{name} on #{inspect(resource)}"
|
||||||
|
|
||||||
resource_subject_input(
|
resource_subject_input(
|
||||||
{resource, Ash.Resource.Info.action(resource, name), input},
|
{resource, action, input},
|
||||||
domain,
|
domain,
|
||||||
actor,
|
actor,
|
||||||
opts
|
opts
|
||||||
)
|
)
|
||||||
|
|
||||||
{%resource{} = record, name} when is_atom(name) and is_atom(resource) ->
|
{%resource{} = record, name}
|
||||||
|
when is_atom(name) and is_atom(resource) and not is_nil(name) ->
|
||||||
|
action =
|
||||||
|
Ash.Resource.Info.action(resource, name) ||
|
||||||
|
raise ArgumentError, "No such action #{name} on #{inspect(resource)}"
|
||||||
|
|
||||||
resource_subject_input(
|
resource_subject_input(
|
||||||
{record, Ash.Resource.Info.action(resource, name), %{}},
|
{record, action, %{}},
|
||||||
domain,
|
domain,
|
||||||
actor,
|
actor,
|
||||||
opts
|
opts
|
||||||
)
|
)
|
||||||
|
|
||||||
{%resource{} = record, name, input} when is_atom(name) and is_atom(resource) ->
|
{%resource{} = record, name, input}
|
||||||
|
when is_atom(name) and is_atom(resource) and not is_nil(name) ->
|
||||||
|
action =
|
||||||
|
Ash.Resource.Info.action(resource, name) ||
|
||||||
|
raise ArgumentError, "No such action #{name} on #{inspect(resource)}"
|
||||||
|
|
||||||
resource_subject_input(
|
resource_subject_input(
|
||||||
{record, Ash.Resource.Info.action(resource, name), input},
|
{record, action, input},
|
||||||
domain,
|
domain,
|
||||||
actor,
|
actor,
|
||||||
opts
|
opts
|
||||||
|
|
Loading…
Reference in a new issue