mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 05:23:03 +12:00
fix: actually use warn_on_empty?
config
This commit is contained in:
parent
32bab0959d
commit
f823e35f7d
3 changed files with 15 additions and 5 deletions
|
@ -183,6 +183,7 @@ locals_without_parens = [
|
||||||
validate_destination_field?: 1,
|
validate_destination_field?: 1,
|
||||||
violation_message: 1,
|
violation_message: 1,
|
||||||
wait_for: 1,
|
wait_for: 1,
|
||||||
|
warn_on_empty?: 1,
|
||||||
where: 1,
|
where: 1,
|
||||||
writable?: 1
|
writable?: 1
|
||||||
]
|
]
|
||||||
|
|
|
@ -36,6 +36,11 @@ defmodule Ash.Registry do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec warn_on_empty?(t()) :: boolean
|
||||||
|
def warn_on_empty?(registry) do
|
||||||
|
Extension.get_opt(registry, [:entries], :warn_on_empty?, true, true)
|
||||||
|
end
|
||||||
|
|
||||||
@spec api_or_api_and_registry(Ash.Api.t() | {Ash.Api.t(), t()}) :: {t(), t()}
|
@spec api_or_api_and_registry(Ash.Api.t() | {Ash.Api.t(), t()}) :: {t(), t()}
|
||||||
def api_or_api_and_registry({api, registry}), do: {api, registry}
|
def api_or_api_and_registry({api, registry}), do: {api, registry}
|
||||||
def api_or_api_and_registry(api), do: {api, api}
|
def api_or_api_and_registry(api), do: {api, api}
|
||||||
|
|
|
@ -3,6 +3,7 @@ defmodule Ash.Registry.Transformers.WarnOnEmpty do
|
||||||
use Ash.Dsl.Transformer
|
use Ash.Dsl.Transformer
|
||||||
|
|
||||||
def transform(registry, dsl) do
|
def transform(registry, dsl) do
|
||||||
|
if Ash.Registry.warn_on_empty?(registry) do
|
||||||
case Ash.Registry.entries(registry) do
|
case Ash.Registry.entries(registry) do
|
||||||
[] ->
|
[] ->
|
||||||
{:warn, dsl, "#{inspect(registry)} has no entries."}
|
{:warn, dsl, "#{inspect(registry)} has no entries."}
|
||||||
|
@ -10,5 +11,8 @@ defmodule Ash.Registry.Transformers.WarnOnEmpty do
|
||||||
_ ->
|
_ ->
|
||||||
{:ok, dsl}
|
{:ok, dsl}
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
{:ok, dsl}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue