Packages

iTunes search API wrapper

Current section

Files

Jump to
itunes lib struct_parser.ex
Raw

lib/struct_parser.ex

defmodule Itunes.StructParser do
@moduledoc false
def to_struct(kind, attrs) do
struct = struct(kind)
Enum.reduce Map.to_list(struct), struct, fn {k, _}, acc ->
case Map.fetch(attrs, Atom.to_string(k)) do
{:ok, v} -> %{acc | k => v}
:error -> acc
end
end
end
end