 defmodule Ehelper.Config do
   @moduledoc false
 
-  @table __MODULE__
-  @agent __MODULE__
+  @table IEx.Config
+  @agent IEx.Config
 
   @keys [
     :doc_helpers]
 
-  def new() do
-    tab = :ets.new(@table, [:named_table, :public])
-    true = :ets.insert_new(tab, [after_spawn: []])
-    tab
-  end
-
-  def delete(__MODULE__) do
-    :ets.delete(__MODULE__)
-  end
 
   def configure(options) do
     Agent.update(@agent, __MODULE__, :handle_configure, [options])

    end
  end

  def after_spawn(fun) do
    Agent.update(@agent, __MODULE__, :handle_after_spawn, [fun])
  end

  def handle_after_spawn(tab, fun) do
    :ets.update_element(tab, :after_spawn, {2, [fun | after_spawn()]})
  end

  def after_spawn() do
    :ets.lookup_element(@table, :after_spawn, 2)
  end

  def started?() do
    Process.whereis(@agent) !== nil
  end

  defp get(key) do
    case Application.fetch_env(:ehelper, key) do
      {:ok, value} ->

    end
  end

end
