Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cereal/builders/base.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Cereal.Builders.Base do
@doc """
Builds a Cereal Base struct that encapsulates the JSON that will be serialized.

Will correctly handle Scrievener pagination.
Will correctly handle Scrivener pagination.
"""
@spec build(Cereal.Context.t()) :: __MODULE__.t()
def build(context)
Expand Down
3 changes: 1 addition & 2 deletions lib/cereal/builders/entity.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ defmodule Cereal.Builders.Entity do

def build(%{data: data} = context) when is_list(data) do
data
|> Task.async_stream(fn entity ->
|> Enum.map(fn entity ->
context
|> Map.put(:data, entity)
|> build()
end)
|> Enum.map(fn {:ok, result} -> result end)
end

def build(%{serializer: serializer} = context) do
Expand Down
6 changes: 1 addition & 5 deletions lib/cereal/formatters/attributes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ defmodule Cereal.Formatters.Attributes do

def format(%Cereal.Builders.Base{data: data}), do: format_data(data)

defp format_data(data) when is_list(data) do
data
|> Task.async_stream(&format_data(&1))
|> Enum.map(fn {:ok, result} -> result end)
end
defp format_data(data) when is_list(data), do: data |> Enum.map(&format_data/1)

defp format_data(%Cereal.Builders.Entity{} = entity) do
entity.attributes
Expand Down