File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- @ moduledoc """
1+ defmodule Ecto.Atom do
2+ @ behaviour Ecto.Type
3+ @ moduledoc """
24
3- You can do
5+ You can do
46
5- defmodule Post do
6- use Ecto.Schema
7- schema "posts" do
8- field :atom_field, Ecto.Atom
7+ defmodule Post do
8+ use Ecto.Schema
9+ schema "posts" do
10+ field :atom_field, Ecto.Atom
11+ end
912 end
10- end
1113
12- to get :atom as you get "string" ;)
13- """
14- defmodule Ecto.Atom do
15- @ behaviour Ecto.Type
14+ to get :atom as you get "string" ;)
15+ """
1616
1717 def type , do: :string
1818
Original file line number Diff line number Diff line change @@ -15,9 +15,15 @@ defmodule Ecto.AtomTest do
1515 end
1616
1717 # `to_string` not working, why ?
18- # test "dump string" do
19- # assert Ecto.Atom.dump("string") == {:ok, "string"}
20- # end
18+ # Can't understand the below comment :/
19+ test "dump string" do
20+ assert Ecto.Atom . dump ( "string" ) == :error
21+ end
22+
23+ test "can load past dumped data" do
24+ { :ok , dumped_atom } = Ecto.Atom . dump :atom
25+ assert Ecto.Atom . load ( dumped_atom ) == { :ok , :atom }
26+ end
2127
2228 test "dump :atom" do
2329 assert Ecto.Atom . dump ( :atom ) == { :ok , "atom" }
You can’t perform that action at this time.
0 commit comments