summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2019-10-15 19:06:47 +0200
committerHubert Chathi <hubert@uhoreg.ca>2019-10-15 19:06:47 +0200
commit5597723489f0a74dbc34d8fde733a7274defcc01 (patch)
tree365444a8350c669dbde549f4f211e4b839fc164f
parentadd another tutorial (diff)
mix format
-rw-r--r--lib/polyjuice/client/filter.ex2
-rw-r--r--lib/polyjuice/client/storage.ex3
-rw-r--r--lib/polyjuice/client/storage/dets.ex6
-rw-r--r--lib/polyjuice/client/storage/ets.ex6
4 files changed, 11 insertions, 6 deletions
diff --git a/lib/polyjuice/client/filter.ex b/lib/polyjuice/client/filter.ex
index 99ce4dd..91e0db2 100644
--- a/lib/polyjuice/client/filter.ex
+++ b/lib/polyjuice/client/filter.ex
@@ -85,6 +85,7 @@ defmodule Polyjuice.Client.Filter do
"""
@spec update(map, [String.t()], Any, (Any -> Any)) :: map
def update(filter, key_path, initial, func)
+
def update(filter, [key], initial, func) when is_map(filter) do
Map.update(filter, key, initial, func)
end
@@ -118,6 +119,7 @@ defmodule Polyjuice.Client.Filter do
"""
@spec put(map, [String.t()], Any) :: map
def put(filter, key_path, val)
+
def put(filter, [key], val) when is_map(filter) do
Map.put(filter, key, val)
end
diff --git a/lib/polyjuice/client/storage.ex b/lib/polyjuice/client/storage.ex
index 21a32c0..a44e53b 100644
--- a/lib/polyjuice/client/storage.ex
+++ b/lib/polyjuice/client/storage.ex
@@ -69,8 +69,7 @@ defprotocol Polyjuice.Client.Storage do
@doc """
Get the data for a specific key.
"""
- @spec kv_get(__MODULE__.t(), String.t(), String.t(), __MODULE__.value()) ::
- __MODULE__.value()
+ @spec kv_get(__MODULE__.t(), String.t(), String.t(), __MODULE__.value()) :: __MODULE__.value()
def kv_get(storage, namespace, key, default \\ nil)
@doc """
diff --git a/lib/polyjuice/client/storage/dets.ex b/lib/polyjuice/client/storage/dets.ex
index c6d578f..6325910 100644
--- a/lib/polyjuice/client/storage/dets.ex
+++ b/lib/polyjuice/client/storage/dets.ex
@@ -67,11 +67,13 @@ defmodule Polyjuice.Client.Storage.Dets do
end
end
- def kv_put(%{table: table}, namespace, key, value) when is_binary(namespace) and is_binary(key) do
+ def kv_put(%{table: table}, namespace, key, value)
+ when is_binary(namespace) and is_binary(key) do
:dets.insert(table, {{"kv", namespace, key}, value})
end
- def kv_get(%{table: table}, namespace, key, default \\ nil) when is_binary(namespace) and is_binary(key) do
+ def kv_get(%{table: table}, namespace, key, default \\ nil)
+ when is_binary(namespace) and is_binary(key) do
case :dets.lookup(table, {"kv", namespace, key}) do
[{_, value}] -> value
_ -> default
diff --git a/lib/polyjuice/client/storage/ets.ex b/lib/polyjuice/client/storage/ets.ex
index 06f7835..3332406 100644
--- a/lib/polyjuice/client/storage/ets.ex
+++ b/lib/polyjuice/client/storage/ets.ex
@@ -62,11 +62,13 @@ defmodule Polyjuice.Client.Storage.Ets do
end
end
- def kv_put(%{table: table}, namespace, key, value) when is_binary(namespace) and is_binary(key) do
+ def kv_put(%{table: table}, namespace, key, value)
+ when is_binary(namespace) and is_binary(key) do
:ets.insert(table, {{"kv", namespace, key}, value})
end
- def kv_get(%{table: table}, namespace, key, default \\ nil) when is_binary(namespace) and is_binary(key) do
+ def kv_get(%{table: table}, namespace, key, default \\ nil)
+ when is_binary(namespace) and is_binary(key) do
case :ets.lookup(table, {"kv", namespace, key}) do
[{_, value}] -> value
_ -> default