Skip to content

Instantly share code, notes, and snippets.

@cpjk
Last active November 25, 2015 04:34
Show Gist options
  • Save cpjk/958eeae3e130648ef47f to your computer and use it in GitHub Desktop.
Save cpjk/958eeae3e130648ef47f to your computer and use it in GitHub Desktop.
defmodule Blog.Abilities do
defimpl Canada.Can, for: Blog.User do
def can?(%Blog.User{}, :index, Blog.User), do: true
def can?(%Blog.User{}, _, _), do: true
def can?(nil, _, _), do: false
end
defimpl Canada.Can, for: nil do
def can?(nil, _, _), do: false
end
end end
@cpjk
Copy link
Author

cpjk commented Nov 25, 2015

When defimpl Canada.Can, for: nil... is removed, the protocol resolved fine for normal users, but not for nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment