parent
1a326cc8aa
commit
034882672a
@ -0,0 +1,20 @@
|
|||||||
|
defmodule DecentralisedBookIndex.Helpers do
|
||||||
|
@moduledoc "Helpers for tests"
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Rerurn a new map with same keys as in map_with_keys.
|
||||||
|
"""
|
||||||
|
def get_submap(map, map_with_keys) when is_map(map_with_keys) do
|
||||||
|
Map.take(map, Map.keys(map_with_keys))
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_submap(map, keys) when is_list(keys) do
|
||||||
|
Map.take(map, keys)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_submaps(map_list, keys) do
|
||||||
|
Enum.map(map_list, fn map ->
|
||||||
|
get_submap(map, keys)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue