Packages

Addict allows you to manage users on your Phoenix app easily. Register, login, logout, recover password and password updating is available off-the-shelf.

Current section

Files

Jump to
addict lib addict presenter.ex
Raw

lib/addict/presenter.ex

defmodule Addict.Presenter do
@moduledoc """
Normalized structure presentation
"""
@doc """
Strips all associations, `:__struct__`, `:__meta__` and `:encrypted_password` from the structure
Returns the stripped structure
"""
def strip_all(model, schema \\ Addict.Configs.user_schema) do
model |> drop_keys(schema)
end
defp drop_keys(model, schema) do
associations = schema.__schema__(:associations)
Map.drop model, associations ++ [:__struct__, :__meta__, :encrypted_password]
end
end