https://github.com/basiliscos/ex-make_enumerable
Makes your defstructs enumerable
https://github.com/basiliscos/ex-make_enumerable
Last synced: 25 days ago
JSON representation
Makes your defstructs enumerable
- Host: GitHub
- URL: https://github.com/basiliscos/ex-make_enumerable
- Owner: basiliscos
- License: mit
- Created: 2018-01-05T20:00:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-06T11:30:48.000Z (over 7 years ago)
- Last Synced: 2025-04-23T20:23:17.512Z (30 days ago)
- Language: Elixir
- Size: 10.7 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MakeEnumerable
[](https://travis-ci.org/basiliscos/ex-make_enumerable)
[](https://hex.pm/packages/make_enumerable)
[](https://github.com/basiliscos/ex-make_enumerable/blob/master/LICENSE)Makes your structures enumerable!
The `MakeEnumerable` module injects `defimpl Enumerable` for your structs,
as structs are basically `maps` with special tag (member) `__struct__`.
The module hides the tag `__struct__` and delegates all other members
to map to be `Enumerable`.```elixir
defmodule Bar do
use MakeEnumerable
defstruct foo: "a", baz: 10
endiex> import Bar
iex> Enum.map(%Bar{}, fn({k, v}) -> {k, v} end)
[baz: 10, foo: "a"]
```## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `make_enumerable` to your list of dependencies in `mix.exs`:```elixir
def deps do
[
{:make_enumerable, "~> 0.0.1"}
]
end
```Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/make_enumerable](https://hexdocs.pm/make_enumerable).