AttrReader (AttrReader v0.2.0)

Can define module attributes getter automatically.

Link to this section Summary

Functions

Defines getters for all custom module attributes if used. And writes getter docs.

Sets module attribute and defines getter. And writes getter docs.

Link to this section Functions

Link to this macro

__using__(opts \\ [])

(macro)

Defines getters for all custom module attributes if used. And writes getter docs.

Examples

iex> defmodule UseAttrReaderForDoc do
...>   @foo "foo"
...>   use AttrReader
...>   @bar :bar
...> end
iex> UseAttrReaderForDoc.foo()
"foo"
iex> UseAttrReaderForDoc.bar()
:bar

iex> defmodule UseAttrReaderForDoc do
...>   @foo "foo"
...>   use AttrReader, only: [:foo]
...>   @bar :bar
...> end
iex> UseAttrReaderForDoc.foo()
"foo"
iex> UseAttrReaderForDoc.bar()
** (UndefinedFunctionError) function AttrReaderTest.UseAttrReaderForDoc.bar/0 is undefined or private

iex> defmodule UseAttrReaderForDoc do
...>   @foo "foo"
...>   use AttrReader, except: [:foo]
...>   @bar :bar
...> end
iex> UseAttrReaderForDoc.bar()
:bar
iex> UseAttrReaderForDoc.foo()
** (UndefinedFunctionError) function AttrReaderTest.UseAttrReaderForDoc.foo/0 is undefined or private
Link to this macro

define(attribute, value \\ nil)

(macro)

Sets module attribute and defines getter. And writes getter docs.

Examples

iex> defmodule AttrReaderMacroForDoc do
...>   AttrReader.define @foo
...>   AttrReader.define @bar, "bar"
...>   AttrReader.define @baz, :baz
...> end
iex> AttrReaderMacroForDoc.foo()
nil
iex> AttrReaderMacroForDoc.bar()
"bar"
iex> AttrReaderMacroForDoc.baz()
:baz