logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

atom.ex (600B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.EctoType.Config.Atom do
  5. use Ecto.Type
  6. def type, do: :atom
  7. def cast(key) when is_atom(key) do
  8. {:ok, key}
  9. end
  10. def cast(key) when is_binary(key) do
  11. {:ok, Pleroma.ConfigDB.string_to_elixir_types(key)}
  12. end
  13. def cast(_), do: :error
  14. def load(key) do
  15. {:ok, Pleroma.ConfigDB.string_to_elixir_types(key)}
  16. end
  17. def dump(key) when is_atom(key), do: {:ok, inspect(key)}
  18. def dump(_), do: :error
  19. end