Skip to content

Commit 75880ee

Browse files
authored
Merge pull request #1246 from code-corps/add-processor-typespecs
Add typespecs for processor
2 parents 3255b64 + 1de5861 commit 75880ee

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

lib/code_corps/accounts/accounts.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ defmodule CodeCorps.Accounts do
123123
|> Repo.update()
124124
end
125125

126+
@spec upload_github_photo_async(User.t) :: User.t | Processor.result
126127
defp upload_github_photo_async(%User{cloudinary_public_id: nil} = user) do
127128
Processor.process(fn -> upload_github_photo(user) end)
128129
end

lib/code_corps/processor/async.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
defmodule CodeCorps.Processor.Async do
22
@behaviour CodeCorps.Processor
33

4+
@spec process((() -> any)) :: {:ok, pid}
45
def process(fun) do
56
Task.Supervisor.start_child(:background_processor, fn ->
67
apply(fun, [])

lib/code_corps/processor/processor.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
defmodule CodeCorps.Processor do
22
@processor Application.get_env(:code_corps, :processor)
33

4-
@callback process(fun :: (() -> any)) :: any
4+
@type result :: {:ok, pid} | any
55

6+
@callback process(fun :: (() -> any)) :: result
7+
8+
@spec process((() -> any)) :: result
69
def process(fun) do
710
@processor.process(fun)
811
end

lib/code_corps/processor/sync.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
defmodule CodeCorps.Processor.Sync do
22
@behaviour CodeCorps.Processor
33

4+
@spec process((() -> any)) :: any
45
def process(fun) do
56
apply(fun, [])
67
end

0 commit comments

Comments
 (0)