TsAccess
Library to generate getters and setters for modules that are using TypedStruct
Installation
If available in Hex, the package can be installed
by adding ts_access to your list of dependencies in mix.exs:
def deps do
[
{:ts_access, "~> 0.1.0"}
]
end
Example
Use TsAccess module as @before_compile and setters/getters will be generated
for module (@before_compile need to by set after use TypedStruct):
defmodule Example do
use TypedStruct
@before_compile TsAccess
typedstruct do
field(:name, :string)
end
end
iex> Example.name(%Example{}, "John Doe")
%Example{name: "John Doe"}
iex> Example.name(%Example{name: "John Doe"})
"John Doe"
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ts_access.