Created
June 8, 2015 18:33
-
-
Save Papipo/008d9d8387d943208c46 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmacro whitelist_literals(literals) do | |
| quote do | |
| for literal <- unquote(literals) do | |
| case literal do | |
| :boolean -> defp allow(exp) when is_boolean(exp), do: exp | |
| :number -> defp allow(exp) when is_number(exp), do: exp | |
| :integer -> defp allow(exp) when is_integer(exp), do: exp | |
| :float -> defp allow(exp) when is_float(exp), do: exp | |
| :tuple -> defp allow(exp) when is_tuple(exp), do: exp | |
| :list -> defp allow(exp) when is_list(exp), do: exp | |
| :map -> defp allow(exp) when is_map(exp), do: exp | |
| unknown -> raise "Unknown literal #{inspect unknown}" | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment