       end
 
       def load(record) do
-        [_table_name |attrs] = Tuple.to_list(record)
-        attrs = Enum.zip(fields(), attrs)
-        struct(table_name(), attrs)
+        [mod |attrs] = Tuple.to_list(record)
+        attrs = Enum.zip(mod.fields(), attrs)
+        struct(mod, attrs)
       end
 
       def fields do

    |> struct.__struct__.get
  end

  def all(module) when is_atom(module) do
    fn ->
      :qlc.e(:mnesia.table module.table_name)

        end

        with {:atomic, [record]} <- :mnesia.transaction(read) do
          {:ok, Mnesia.Repo.load(record)}
        else
          {:atomic, []} ->
            {:error, %Mnesia.RecordNotFoundError{id: id, table: table_name()}}
