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

View Source

A base module for Commanded DSL transformers.

This module provides common functionality for transformers that generate code based on the Commanded DSL configuration.

Summary

Functions

Converts an atom to CamelCase string.

Creates a module with the given name and contents.

Gets the module prefix for generated modules.

Gets the resource name from the resource module.

Functions

camelize_atom(atom)

@spec camelize_atom(atom()) :: String.t()

Converts an atom to CamelCase string.

Examples

iex> camelize_atom(:register_user)
"RegisterUser"

create_module(module_name, ast, env)

@spec create_module(module(), Macro.t(), Macro.Env.t()) :: :ok

Creates a module with the given name and contents.

This is a wrapper around Module.create/3 that handles the environment location.

Examples

iex> create_module(MyApp.Commands.RegisterUser, quoted_ast, __ENV__)
:ok

get_module_prefix(resource_module)

@spec get_module_prefix(module()) :: module()

Gets the module prefix for generated modules.

This extracts the base namespace from the resource module, which will be used as the prefix for all generated modules.

Examples

iex> get_module_prefix(MyApp.Accounts.User)
MyApp.Accounts

get_resource_name(resource_module)

@spec get_resource_name(module()) :: String.t()

Gets the resource name from the resource module.

Examples

iex> get_resource_name(MyApp.Accounts.User)
"User"