Packages

The non-official Elixir implementation for Azure Cognitive Services Speech SDK. This project aims to provide all the functionalities described in the official sdk

Current section

Files

Jump to
ex_azure_speech lib ex_azure_speech common key_value.ex
Raw

lib/ex_azure_speech/common/key_value.ex

defmodule ExAzureSpeech.Common.KeyValue do
@moduledoc """
Provides a macro for defining a module with a set of key-value pairs.
"""
defmacro __using__(options) do
quote bind_quoted: [options: options] do
@type t() :: unquote(options |> Keyword.keys() |> Enum.reduce(&{:|, [], [&1, &2]}))
defmacro values() do
Enum.map(unquote(options), fn {_function_name, value} ->
value
end)
end
for {function_name, value} <- options do
@doc false
@spec unquote(function_name)() :: String.t()
def unquote(function_name)(), do: unquote(value)
end
end
end
end