Current section

Files

Jump to
ash_outstanding lib resource transformer.ex
Raw

lib/resource/transformer.ex

# SPDX-FileCopyrightText: 2025 ash_outstanding contributors <https://github.com/diffo-dev/ash_outstanding/graphs.contributors>
#
# SPDX-License-Identifier: MIT
defmodule AshOutstanding.Resource.Transformer do
@moduledoc false
use Spark.Dsl.Transformer
@impl true
def transform(dsl) do
AshOutstanding.TransformerHelper.transform(dsl, fn dsl, options ->
fields = Ash.Resource.Info.fields(dsl)
fields = if Map.get(options, :private?), do: fields, else: Enum.filter(fields, & &1.public?)
fields = if Map.get(options, :sensitive?), do: fields, else: Enum.reject(fields, &Map.get(&1, :sensitive?))
fields
end)
end
end