Current section
Files
Jump to
Current section
Files
lib/ecto_rut.ex
defmodule Ecto.Rut do
defmacro __using__(_) do
quote do
def all(opts \\ []) do
apply(repo, :all, [__MODULE__, opts])
end
def get(id, opts \\ []) do
apply(repo, :get, [__MODULE__, id, opts])
end
def get!(id, opts \\ []) do
apply(repo, :get!, [__MODULE__, id, opts])
end
def insert(struct, opts \\ []) do
apply(repo, :insert, [struct, opts])
end
def insert!(struct, opts \\ []) do
apply(repo, :insert!, [struct, opts])
end
def delete(struct, opts \\ []) do
apply(repo, :delete, [struct, opts])
end
def delete!(struct, opts \\ []) do
apply(repo, :delete!, [struct, opts])
end
# Private Methods
defp repo do
Module.concat(parent_module, "Repo")
end
defp parent_module do
__MODULE__
|> Module.split
|> Enum.drop(-1)
|> Module.concat
end
end
end
end