Skip to content
This repository was archived by the owner on Apr 11, 2019. It is now read-only.

Commit ddbcf81

Browse files
author
José Valim
committed
Registry.update -> Registry.update_value
1 parent dcb46e0 commit ddbcf81

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

examples/sojourn.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ defmodule Registry.Sojourn do
7878
receive_time = System.system_time
7979

8080
update =
81-
Registry.update(name, key, fn _ ->
81+
Registry.update_value(name, key, fn _ ->
8282
{-send_time, receive_time - send_time}
8383
end)
8484

lib/registry.ex

+4-4
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,14 @@ defmodule Registry do
259259
iex> {:ok, _} = Registry.register(Registry.UpdateTest, "hello", 1)
260260
iex> Registry.lookup(Registry.UpdateTest, "hello")
261261
[{self(), 1}]
262-
iex> Registry.update(Registry.UpdateTest, "hello", & &1 + 1)
262+
iex> Registry.update_value(Registry.UpdateTest, "hello", & &1 + 1)
263263
{2, 1}
264264
iex> Registry.lookup(Registry.UpdateTest, "hello")
265265
[{self(), 2}]
266266
267267
"""
268-
@spec update(registry, key, (value -> value)) :: {new_value :: term, old_value :: term} | :error
269-
def update(registry, key, callback) when is_atom(registry) and is_function(callback, 1) do
268+
@spec update_value(registry, key, (value -> value)) :: {new_value :: term, old_value :: term} | :error
269+
def update_value(registry, key, callback) when is_atom(registry) and is_function(callback, 1) do
270270
case info!(registry) do
271271
{:unique, partitions, key_ets, _} ->
272272
key_ets = key_ets || key_ets!(registry, key, partitions)
@@ -283,7 +283,7 @@ defmodule Registry do
283283
:error
284284
end
285285
{kind, _, _, _} ->
286-
raise ArgumentError, "Registry.update/3 is not supported for #{kind} registries"
286+
raise ArgumentError, "Registry.update_value/3 is not supported for #{kind} registries"
287287
end
288288
end
289289

test/registry_test.exs

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ defmodule RegistryTest do
5454
end
5555

5656
test "updates current process value", %{registry: registry} do
57-
assert Registry.update(registry, "hello", &raise/1) == :error
57+
assert Registry.update_value(registry, "hello", &raise/1) == :error
5858
register_task(registry, "hello", :value)
59-
assert Registry.update(registry, "hello", &raise/1) == :error
59+
assert Registry.update_value(registry, "hello", &raise/1) == :error
6060

6161
Registry.register(registry, "world", 1)
6262
assert Registry.lookup(registry, "world") == [{self(), 1}]
63-
assert Registry.update(registry, "world", & &1 + 1) == {2, 1}
63+
assert Registry.update_value(registry, "world", & &1 + 1) == {2, 1}
6464
assert Registry.lookup(registry, "world") == [{self(), 2}]
6565
end
6666

0 commit comments

Comments
 (0)