-
-
Save churcho/844e5bef5baa71a6d5d26167c2215a80 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