Created
December 3, 2014 01:36
-
-
Save alanpeabody/eaa72deeef8f3c630a36 to your computer and use it in GitHub Desktop.
silly_long_elixir_function_pattern_match.ex
This file contains 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
defmodule Post do | |
def create(%{title: t, body: b, author_id: a} = atts) when is_binary(t) and is_binary(b) and is_binary(a) do | |
{:ok, Dict.merge(atts, :id, 1234)} | |
end | |
def create(_atts) do | |
{:error, %{error: "Invalid attributes"}} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment