@impl true
def transform(dsl_state) do
module = Spark.Dsl.Transformer.get_persisted(dsl_state, :module)
inferred_attrs = InferredAttributes.Info.inferred_attributes(dsl_state)
Enum.reduce_while(inferred_attrs, {:ok, dsl_state}, fn attr, {:ok, dsl_state} ->
attribute = Ash.Resource.Info.attribute(dsl_state, attr.name)
if !attribute do
raise Spark.Error.DslError,
module: module,
message: "No attribute called #{attr.name} found",
path: [:inferred_attributes, attr.name]
end
if attribute.primary_key? do
raise Spark.Error.DslError,
module: module,
message: "Cannot infer primary key attribute",
path: [:inferred_attributes, attr.name]
end
{:cont, {:ok, dsl_state}}
end)
end
@impl true
def transform(dsl_state) do
module = Spark.Dsl.Transformer.get_persisted(dsl_state, :module)
inferred_attrs = InferredAttributes.Info.inferred_attributes(dsl_state)
Enum.reduce_while(inferred_attrs, {:ok, dsl_state}, fn attr, {:ok, dsl_state} ->
attribute = Ash.Resource.Info.attribute(dsl_state, attr.name)
if !attribute do
raise Spark.Error.DslError,
module: module,
message: "No attribute called #{attr.name} found",
path: [:inferred_attributes, attr.name]
end
if attribute.primary_key? do
raise Spark.Error.DslError,
module: module,
message: "Cannot infer primary key attribute",
path: [:inferred_attributes, attr.name]
end
{:cont, {:ok, dsl_state}}
end)
end