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,
|
||||
violation_message: 1,
|
||||
wait_for: 1,
|
||||
warn_on_empty?: 1,
|
||||
where: 1,
|
||||
writable?: 1
|
||||
]
|
||||
|
|
|
@ -36,6 +36,11 @@ defmodule Ash.Registry do
|
|||
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()}
|
||||
def api_or_api_and_registry({api, registry}), do: {api, registry}
|
||||
def api_or_api_and_registry(api), do: {api, api}
|
||||
|
|
|
@ -3,12 +3,16 @@ defmodule Ash.Registry.Transformers.WarnOnEmpty do
|
|||
use Ash.Dsl.Transformer
|
||||
|
||||
def transform(registry, dsl) do
|
||||
case Ash.Registry.entries(registry) do
|
||||
[] ->
|
||||
{:warn, dsl, "#{inspect(registry)} has no entries."}
|
||||
if Ash.Registry.warn_on_empty?(registry) do
|
||||
case Ash.Registry.entries(registry) do
|
||||
[] ->
|
||||
{:warn, dsl, "#{inspect(registry)} has no entries."}
|
||||
|
||||
_ ->
|
||||
{:ok, dsl}
|
||||
_ ->
|
||||
{:ok, dsl}
|
||||
end
|
||||
else
|
||||
{:ok, dsl}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue