Skip to content

Commit

Permalink
Fix specs.
Browse files Browse the repository at this point in the history
Add a little bit more docs to `gen`
  • Loading branch information
mrmicahcooper committed Oct 10, 2019
1 parent 78a3446 commit a9af533
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/ecto_factory.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ defmodule EctoFactory do

# Generators for the standard ecto types
@doc """
generate a random value
Generate a random value. `gen/1` will return a value of the atom or tuple to pass it.
"""
@spec gen(:atom | tuple()) ::
@spec gen(atom() | tuple()) ::
integer()
| binary()
| float()
Expand Down Expand Up @@ -130,10 +130,8 @@ defmodule EctoFactory do
{schema, attrs}
end

defp gen_attribute({key, value}) when is_atom(value) or is_tuple(value) do
{key, gen(value)}
end

defp gen_attribute({key, value}) when is_atom(value), do: {key, gen(value)}
defp gen_attribute({key, {_, _} = value}), do: {key, gen(value)}
defp gen_attribute(key_value), do: key_value

defp cast({key, {:assoc, %{cardinality: :many}}}), do: {key, nil}
Expand Down

0 comments on commit a9af533

Please sign in to comment.