Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
600B

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2021 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