Created
February 17, 2017 11:18
-
-
Save pedrosmmoreira/5d5e5dc5c3bd95ae8b1b64bafce0d921 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class FooPolicy < ApplicationPolicy | |
| #... | |
| class Scope | |
| #... | |
| def resolve | |
| if user.roles.include?("admin") | |
| scope.not_cancelled | |
| elsif user.roles.include?("official") | |
| scope.not_draft | |
| elsif user.roles.include?("provider") | |
| scope.provided_by(user) | |
| else | |
| scope.none | |
| end | |
| end | |
| end | |
| def show? | |
| (provider && !record.cancelled?) || | |
| (official || user_is_assigned_provider?(user)) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment