Top Level Namespace
Defined in:
Macro Summary
-
args
Creates a NamedTuple containing the arguments of the surround method.
-
mapped_enum(name, &block)
Defines a enum where each member holds a reference to an associated value.
Macro Detail
macro args
#
Creates a NamedTuple containing the arguments of the surround method.
This can be used as an alternative to a double splat arg to enforce a strict type, but provide a simple accessor for methods acting as a thin proxy.
macro mapped_enum(name, &block)
#
Defines a enum where each member holds a reference to an associated value.
This may be used to define enum over non-integer types, whilst keeping the same type safety that integer-backed enums provide.
mapped_enum Example do
A = "foo"
B = "bar"
C = "baz"
end
Members may statically accessed from mapped values
Example["foo"] # => Example::A
Or resolved dynamically
value = "foo"
Example.from_mapped_value value # => Example::A
Mapped values may also be extracted
Example::A.mapped_value # => "foo"
All other functionality, performance and safety that enums provide holds.