Skip to content

Commit

Permalink
Merge branch 'Simon-Initiative:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dtiwarATS committed Mar 21, 2024
2 parents 542c2c8 + c8c8d01 commit 6e47c1e
Show file tree
Hide file tree
Showing 3 changed files with 327 additions and 52 deletions.
11 changes: 11 additions & 0 deletions lib/oli/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,15 @@ defmodule Oli.Utils do
Converts an atom into a readable string by replacing underscores with empty spaces.
"""
def stringify_atom(atom), do: atom |> Atom.to_string() |> String.replace("_", " ")

@doc """
Returns the value from a nested map given a list of keys. If the value is not found, returns the default value.
"""
@spec get_in(map :: map, keys :: list, default :: any) :: any
def get_in(map, keys, default) do
case get_in(map, keys) do
nil -> default
value -> value
end
end
end
Loading

0 comments on commit 6e47c1e

Please sign in to comment.