AshCommanded.Commanded.Transformers.GenerateCommandModules (AshCommanded v0.1.0)

View Source

Generates command modules based on the commands defined in the DSL.

For each command defined in a resource, this transformer will generate a corresponding module with the command name as a struct with the specified fields.

This transformer should run before any other code generation transformers.

Example

Given a resource with the following command:

command :register_user do
  fields [:id, :email, :name]
  identity_field :id
end

This transformer will generate a module like:

defmodule MyApp.Commands.RegisterUser do
  @moduledoc "Command for registering a user"
  
  @type t :: %__MODULE__{
    id: String.t(),
    email: String.t(),
    name: String.t()
  }
  
  defstruct [:id, :email, :name]
end

Summary

Functions

Callback implementation for Spark.Dsl.Transformer.after?/1.

Specifies that this transformer should run before the event module transformer.

Transforms the DSL state to generate command modules.

Functions

after?(_)

Callback implementation for Spark.Dsl.Transformer.after?/1.

after_compile?()

Callback implementation for Spark.Dsl.Transformer.after_compile?/0.

before?(arg1)

Specifies that this transformer should run before the event module transformer.

transform(dsl_state)

Transforms the DSL state to generate command modules.

Examples

iex> transform(dsl_state)
updated_dsl_state