You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: lib/typed_structor.ex
+39-79
Original file line number
Diff line number
Diff line change
@@ -20,10 +20,31 @@ defmodule TypedStructor do
20
20
21
21
* `:module` - if provided, a new submodule will be created with the struct.
22
22
* `:enforce` - if `true`, the struct will enforce the keys, see `field/3` options for more information.
23
-
* `:define_struct` - if `false`, the type will be defined, but the struct will not be defined. Defaults to `true`.
23
+
* `:definer` - the definer module to use to define the struct, record or exception. Defaults to `:defstruct`. It also accepts a macro that receives the definition struct and returns the AST. See definer section below.
24
24
* `:type_kind` - the kind of type to use for the struct. Defaults to `type`, can be `opaque` or `typep`.
25
25
* `:type_name` - the name of the type to use for the struct. Defaults to `t`.
26
26
27
+
## Definer
28
+
There are one available definer for now, `:defstruct`, which defines a struct and a type for a given definition.
29
+
30
+
### `:defstruct` options
31
+
32
+
* `:define_struct` - if `false`, the type will be defined, but the struct will not be defined. Defaults to `true`.
33
+
34
+
### custom definer
35
+
36
+
defmodule MyStruct do
37
+
# you must require the definer module to use its define/1 macro
0 commit comments