View Source MapWithIndifferentAccess
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:
You need to use atom keys when calling the functions. (Even if the map uses string keys.)
If the map uses string keys,
key
argument will be converted to a string, and only then called with a respectiveMap
function.
usage-example
Usage example
See API reference.
contributing
Contributing
running-tests
Running tests
Run the following after cloning the repo:
mix deps.get
mix test