Skip to content

Instantly share code, notes, and snippets.

@drusepth
Last active August 17, 2017 00:36
Show Gist options
  • Save drusepth/327a498ceb5a95b37118daa45518db24 to your computer and use it in GitHub Desktop.
Save drusepth/327a498ceb5a95b37118daa45518db24 to your computer and use it in GitHub Desktop.
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