/ts_access

Elixir TypedStruct accessor generator

Primary LanguageElixirMIT LicenseMIT

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, "~> 1.0.1"}
  ]
end

Example

Use TsAccess and setters/getters will be generated for module (use TsAccess need to be after use TypedStruct):

defmodule Example do
  use TypedStruct
  use 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.

Change Log

  • 1.0.1 - fix TsAccess.Lenses module docs
  • 1.0.0 - removed _lens generated functions, added @doc to generated functions
  • 0.7.0 - remove lenses function postfix _lens, generated lenses consider default values
  • 0.6.0 - added lenses
  • 0.5.0 - added explicit use mode
  • 0.3.0 - added use interface
  • 0.4.0 - improve generated functions, defgetter/defsetter macros