diff --git a/lib/remodel/formatters/list_formatter.ex b/lib/remodel/formatters/list_formatter.ex index 0e97e11..e2efbeb 100644 --- a/lib/remodel/formatters/list_formatter.ex +++ b/lib/remodel/formatters/list_formatter.ex @@ -13,15 +13,15 @@ defmodule Remodel.Formatter.ListFormatter do do: Enum.map(resources, fn(resource) -> format_resources(resource, serializer, options) end) defp format_resources(resource, serializer, options) do - Enum.map serializer.__attributes, fn(attr) -> + Enum.map(serializer.__attributes(), fn(attr) -> if !attr.if || apply(serializer, attr.if, [resource, options[:scope]]) do apply(serializer, attr.attribute, [resource, options[:scope]]) else nil end - end + end) end defp format_header(serializer), - do: Enum.map(serializer.__attributes, fn(attr) -> to_string(attr.as || attr.attribute) end) + do: Enum.map(serializer.__attributes(), fn(attr) -> to_string(attr.as || attr.attribute) end) end diff --git a/lib/remodel/formatters/map_formatter.ex b/lib/remodel/formatters/map_formatter.ex index 8bc00cd..74ab0a7 100644 --- a/lib/remodel/formatters/map_formatter.ex +++ b/lib/remodel/formatters/map_formatter.ex @@ -11,7 +11,7 @@ defmodule Remodel.Formatter.MapFormatter do end defp format_resource(resource, serializer, options) when is_map(resource) do - Enum.reduce(serializer.__attributes, %{}, fn(attr, results) -> + Enum.reduce(serializer.__attributes(), %{}, fn(attr, results) -> if !attr.if || evaluate_conditional(resource, serializer, options, attr) do Map.put(results, attr.as || attr.attribute, apply(serializer, attr.attribute, [resource, options[:scope]])) else