You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
465 B
21 lines
465 B
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
|