Refactor Tracker get/0 and summarize/0
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user