Defconst.Enum.DefaultGenerator (Defconst v0.4.0)

Copy Markdown View Source

Default implementation of enum generator

Summary

Functions

Returns the next enum value from the previous one.

Functions

next_value(constant_name, previous_value)

@spec next_value(atom(), integer()) :: integer()
@spec next_value(atom(), String.t()) :: String.t()

Returns the next enum value from the previous one.

When the previous value is an integer, returns it incremented by one. When the previous value is a binary, returns it with "1" appended.

Examples:

iex> Defconst.Enum.DefaultGenerator.next_value(:three, 2)
3

iex> Defconst.Enum.DefaultGenerator.next_value(:bye, "hello")
"hello1"