DynamicModule v0.1.7 DynamicModule View Source
Generate a new module based on AST.
Link to this section Summary
Functions
Generate .beam
and .ex
files based on
Generate module name based on app
, prefix
and name
. The postfix
is optional
Normalize name to atom
Link to this section Functions
Link to this macro
gen(mod_name, preamble, contents, opts \\ []) View Source (macro)
Generate .beam
and .ex
files based on:
mod_name
- the module namepreamble
- the module attibutes and directives in AST, e.g.use GenServer
,require Logger
, etccontents
- the module body in AST
Options
:doc
- the documents to the module. Defaults tofalse
:path
- the path for generated.ex
files. Defaults to""
:create
- a boolean value indicates whether to create.beam
file. Defaults totrue
Link to this function
gen_module_name(app, prefix, name, postfix \\ "") View Source
Generate module name based on app
, prefix
and name
. The postfix
is optional.
Examples
iex> DynamicModule.gen_module_name(:app, "Prefix", "name")
"App.Prefix.Name"
iex> DynamicModule.gen_module_name(:app, "Prefix", "name", "Postfix")
"App.Prefix.Name.Postfix"
Link to this function
normalize_name(name) View Source
Normalize name to atom.
Examples
iex> DynamicModule.normalize_name("a")
:a
iex> DynamicModule.normalize_name(:abc)
:abc