Skip to content

Commit

Permalink
fix: typespecs (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitridewit authored Mar 26, 2021
1 parent d8cf2af commit 9f67f3c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/paper_trail/version_queries.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ defmodule PaperTrail.VersionQueries do
def get_versions(model, id) when is_atom(model) and is_integer(id),
do: get_versions(model, id, [])

@spec get_versions(record :: Ecto.Schema.t(), options :: []) :: [Version.t()]
@spec get_versions(record :: Ecto.Schema.t(), options :: keyword | []) :: [Version.t()]
def get_versions(record, options) when is_map(record) do
item_type = record.__struct__ |> Module.split() |> List.last()

version_query(item_type, PaperTrail.get_model_id(record), options)
|> PaperTrail.RepoClient.repo().all
end

@spec get_versions(model :: module, id :: pos_integer, options :: []) :: [Version.t()]
@spec get_versions(model :: module, id :: pos_integer, options :: keyword | []) :: [Version.t()]
def get_versions(model, id, options) do
item_type = model |> Module.split() |> List.last()
version_query(item_type, id, options) |> PaperTrail.RepoClient.repo().all
Expand All @@ -59,15 +59,15 @@ defmodule PaperTrail.VersionQueries do
def get_version(model, id) when is_atom(model) and is_integer(id),
do: get_version(model, id, [])

@spec get_version(record :: Ecto.Schema.t(), options :: []) :: Version.t() | nil
@spec get_version(record :: Ecto.Schema.t(), options :: keyword | []) :: Version.t() | nil
def get_version(record, options) when is_map(record) do
item_type = record.__struct__ |> Module.split() |> List.last()

last(version_query(item_type, PaperTrail.get_model_id(record), options))
|> PaperTrail.RepoClient.repo().one
end

@spec get_version(model :: module, id :: pos_integer, options :: []) :: Version.t() | nil
@spec get_version(model :: module, id :: pos_integer, options :: keyword | []) :: Version.t() | nil
def get_version(model, id, options) do
item_type = model |> Module.split() |> List.last()
last(version_query(item_type, id, options)) |> PaperTrail.RepoClient.repo().one
Expand Down

0 comments on commit 9f67f3c

Please sign in to comment.