Box.Map (box v0.15.1)
View SourceExtra functions to work with map.
Specifically, this include function to work with maps independent of the key type. These functions should be used everywhere we manipulate changeset params to ensure they both work with string and atom maps and support UI inputs as well as console input.
Summary
Functions
Gets a value in a map from key. The provided needs to be an atom though it'll automatically be converted to a string if the map is string keyed.
Gets first entry that matches in the map
Gets a value from a key in a map with a default value. Unlike Map.get/3, this function will return the default even if the key exists but the value is nil.
Maps map values within the same key
Puts a value in a map. The provided needs to be an atom though it'll automatically be converted to a string if the map is string keyed.
Puts a new value in a map. The provided needs to be an atom though it'll automatically be converted to a string if the map is string keyed.
Puts a new lazy value in a map. The provided needs to be an atom though it'll automatically be converted to a string if the map is string keyed.
Renames a key
Takes only the given keys no matter the key type
Updates a map value from its key only if it exists
Functions
Gets a value in a map from key. The provided needs to be an atom though it'll automatically be converted to a string if the map is string keyed.
Gets first entry that matches in the map
Gets a value from a key in a map with a default value. Unlike Map.get/3, this function will return the default even if the key exists but the value is nil.
Maps map values within the same key
Puts a value in a map. The provided needs to be an atom though it'll automatically be converted to a string if the map is string keyed.
Puts a new value in a map. The provided needs to be an atom though it'll automatically be converted to a string if the map is string keyed.
Puts a new lazy value in a map. The provided needs to be an atom though it'll automatically be converted to a string if the map is string keyed.
Renames a key
Takes only the given keys no matter the key type
Updates a map value from its key only if it exists