Skip to content

Commit a60fef4

Browse files
author
julien-leclercq
committed
cleaning and adding ecto as dep
1 parent 42b7921 commit a60fef4

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

lib/ecto_atom.ex

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ defmodule Ecto.Atom do
1717
def type, do: :string
1818

1919
def cast(value) when is_atom(value), do: {:ok, value}
20-
# `to_string` not working, why ?
21-
# def cast(value) when is_string(value), do: {:ok, String.to_atom(value)}
2220
def cast(_), do: :error
2321

2422
def load(value), do: {:ok, String.to_atom(value)}
2523

2624
def dump(value) when is_atom(value), do: {:ok, Atom.to_string(value)}
27-
# `to_string` not working, why ?
28-
# def dump(value) when is_string(value), do: {:ok, value}
2925
def dump(_), do: :error
26+
3027
end

mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ defmodule Ecto.Atom.Mixfile do
2828
#
2929
# Type "mix help deps" for more examples and options
3030
defp deps do
31-
[]
31+
[{:ecto, "~> 2.1"}]
3232
end
3333
end

mix.lock

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%{"decimal": {:hex, :decimal, "1.4.0", "fac965ce71a46aab53d3a6ce45662806bdd708a4a95a65cde8a12eb0124a1333", [:mix], []},
2+
"ecto": {:hex, :ecto, "2.1.4", "d1ba932813ec0e0d9db481ef2c17777f1cefb11fc90fa7c142ff354972dfba7e", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, optional: true]}]},
3+
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []}}

test/ecto_atom_test.exs

+4-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ defmodule Ecto.AtomTest do
1414
assert Ecto.Atom.load("string") == {:ok, :string}
1515
end
1616

17-
# `to_string` not working, why ?
18-
# Can't understand the below comment :/
19-
test "dump string" do
20-
assert Ecto.Atom.dump("string") == :error
21-
end
22-
2317
test "can load past dumped data" do
2418
{ :ok, dumped_atom } = Ecto.Atom.dump :atom
2519
assert Ecto.Atom.load(dumped_atom) == { :ok, :atom }
@@ -28,4 +22,8 @@ defmodule Ecto.AtomTest do
2822
test "dump :atom" do
2923
assert Ecto.Atom.dump(:atom) == {:ok, "atom"}
3024
end
25+
26+
test "dump string" do
27+
assert Ecto.Atom.dump("string") == :error
28+
end
3129
end

0 commit comments

Comments
 (0)