Skip to content

Commit 8487598

Browse files
committed
default options
1 parent 4213aff commit 8487598

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/atomic_map.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
defmodule AtomicMap do
2-
2+
def convert(v, opts \\ [])
33
def convert(map, opts) when is_map(map) do
44
safe = Keyword.get(opts, :safe, true)
55
map |> Enum.reduce(%{}, fn({k,v}, acc)->

test/atomic_map_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ defmodule AtomicMapTest do
3232
assert AtomicMap.convert(input, safe: true) == expected
3333
end
3434

35+
test "works with default opts" do
36+
input = "2"
37+
expected = "2"
38+
assert AtomicMap.convert(input) == expected
39+
end
40+
3541
test "raises for not existing atoms" do
3642
assert_raise ArgumentError, fn ->
3743
input = %{"a" => 2, "b" => %{"c" => 4}, "__not___existing__" => 5}

0 commit comments

Comments
 (0)