Refactor Tracker get/0 and summarize/0

This commit is contained in:
Jay Hayes
2016-04-26 18:16:17 -05:00
parent 93c41d6ced
commit 814d3db995
3 changed files with 7 additions and 7 deletions

View File

@@ -10,7 +10,6 @@ defmodule Tracker do
def get do
Agent.get(__MODULE__, &(&1))
|> summarize
end
def completed(koan) do
@@ -20,11 +19,12 @@ defmodule Tracker do
end
def complete? do
{total, completed} = Agent.get(__MODULE__, &(&1))
{total, completed} = get
total == Enum.count(completed)
end
def summarize({total, completed}) do
def summarize, do: get |> summarize
defp summarize({total, completed}) do
%{total: total, current: MapSet.size(completed)}
end
end