map_rewire v0.1.1 MapRewire
Syntactic sugar to simply bulk rekey maps. MapRewire takes two arguments, data (map) and transformation (list of transformations / string of transformations separated by whitespace).
- Main Syntax:
left<~>right(content<~>transformation). Left value is the map that holds the data and keys you would like to update, Right value is an Elixir List that contains a string for each of the keys that you would like to update. - Transformation Syntax:
left=>right(from=>to). Left is the original key, right is the new key. - Return Syntax:
[left, right]([ original, rekeyed ]).leftis the original map.rightis the new, rekeyed, map.
Link to this section Summary
Functions
Macro syntax sugar to enable calling rewire in an elixir like way
Maps over the Enum content and replaces the key if it matches with an item in list
Link to this section Functions
Macro syntax sugar to enable calling rewire in an elixir like way.
Input params:
datais passed ascontenttransformsis passed aslistorbinary.
Output:
[left, right] ([ original, rekeyed ]). left is the original map. right is the new, rekeyed, map.
Maps over the Enum content and replaces the key if it matches with an item in list.
Example 1:
MapRewire.rewrite(%{"id"=>"234923409", "title"=>"asdf"}, ~w(title=>name id=>shopify_id))
Example 2:
MapRewire.rewrite(%{"id"=>"234923409"}, ['id=>shopify_id'])