View Source Flamel.Map.Indifferent (flamel v1.10.0)
A set of helper functions for accessing a map with indifferent access. These functions are inspired by the behavior of Ruby/Rails, where keys in a hash can be accessed with indifferent access.
Summary
Functions
Get a value from a map whether the key is a string or atom
Functions
Get a value from a map whether the key is a string or atom
Examples
iex> Flamel.Map.Indifferent.get(%{test: "value"}, "test")
"value"
iex> Flamel.Map.Indifferent.get(%{test: "value"}, :test)
"value"
iex> Flamel.Map.Indifferent.get(%{"test" => "value"}, :test)
"value"
iex> Flamel.Map.Indifferent.get(%{"test" => "value"}, "test")
"value"
iex> Flamel.Map.Indifferent.get(%{"test" => "value"}, "does-not-exist", "default")
"default"