Last active
August 23, 2016 16:41
-
-
Save cpjk/015186c42b674bf7a01f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Abilities1 do | |
defimpl Canada.Can, for: User do | |
def can?(%User{id: user_id}, action, %Testimonial{id: testimonial_id}) | |
when action in [:create], do: true | |
def can?(%User{id: user_id}, action, %Testimonial{id: testimonial_id}) | |
when action in [:edit], do: true | |
end | |
end | |
defmodule BetterAbilities do | |
defimpl Canada.Can, for: User do | |
# We can declare both action permissions in a single statement | |
def can?(%User{id: user_id}, action, %Testimonial{id: testimonial_id}) | |
when action in [:create, :edit], do: true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment