Current section
Files
Jump to
Current section
Files
lib/transformers/ensure_state_selected.ex
# SPDX-FileCopyrightText: 2023 ash_state_machine contributors <https://github.com/ash-project/ash_state_machine/graphs/contributors>
#
# SPDX-License-Identifier: MIT
defmodule AshStateMachine.Transformers.EnsureStateSelected do
# Ensures that `state` is always selected on queries.
@moduledoc false
use Spark.Dsl.Transformer
def transform(dsl_state) do
Ash.Resource.Builder.add_preparation(
dsl_state,
{Ash.Resource.Preparation.Build,
ensure_selected: [
AshStateMachine.Info.state_machine_state_attribute(dsl_state)
]}
)
end
end