Skip to content

Instantly share code, notes, and snippets.

@drusepth
Created July 7, 2019 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drusepth/400159608252d838a99ef659a4bb0a2d to your computer and use it in GitHub Desktop.
Save drusepth/400159608252d838a99ef659a4bb0a2d to your computer and use it in GitHub Desktop.
Rails.application.config.content_types[:premium].each do |content_type|
authorizer_class_name = "#{content_type.name}ContentAuthorizer"
Object.const_set(authorizer_class_name, Class.new(ContentAuthorizer) do
def self.createable_by?(user)
return false if ENV.fetch('CONTENT_BLACKLIST')&.split(',')&.include?(user.email)
[
PermissionService.billing_plan_allows_extended_content?(user: user),
PermissionService.user_can_collaborate_in_universe_that_allows_extended_content?(user: user),
PermissionService.user_has_active_promotion_for_this_content_type(user: user, content_type: content_type.name)
].any?
end
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment