Last active
August 17, 2017 00:36
-
-
Save drusepth/327a498ceb5a95b37118daa45518db24 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 UniverseCoreContentAuthorizer < CoreContentAuthorizer | |
def self.creatable_by? user | |
user.universes.count < (user.active_billing_plans.map(&:universe_limit).max || 5) | |
end | |
def readable_by? user | |
[ | |
resource.user_id == user.id, | |
resource.privacy == 'public', | |
user.contributable_universes.pluck(:id).include?(resource.id) | |
].any? | |
end | |
def updatable_by? user | |
[ | |
resource.user_id == user.id, | |
user.contributable_universes.pluck(:id).include?(resource.id) | |
].any? | |
end | |
def deletable_by? user | |
resource.user_id == user.id | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment