View Source MapWithIndifferentAccess

Build Status Documentation

Utility functions making it easier to work with maps which can either have atom keys or string keys, but never both.

For example, you'll find it useful when working with Ecto.Changeset, as Ecto.Changeset.cast/4 forbids passing maps with mixed key types.

Nearly all functions mimic Map interface, e.g. MapWithIndifferentAccess.put/3 works just as Map.put/3, with two important differences:

  1. You need to use atom keys when calling the functions. (Even if the map uses string keys.)

  2. If the map uses string keys, key argument will be converted to a string, and only then called with a respective Map function.


Usage example

See API reference.




Running tests

Run the following after cloning the repo:

mix deps.get
mix test