You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: team.rb
    path of file: ./repos/role_core/test/dummy/app/models
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class Team < ApplicationRecord
  validates :name,
            presence: true,
            uniqueness: true

  before_save :write_permissions
  before_validation :validate_permissions

  def permissions
    @permissions ||= permission_set_class.load self[:permissions]
  end

  def permissio
    
    def permission_set_class
      @permission_set_class ||=
        begin
          # You MAY need to cache this if you meet N+1 issue here.
          # Consider caching at app start.
          # Don't forget to refresh the cache when permission definition changed.
          dynamic_permissions = DynamicPermission.all

          RoleCore::PermissionSet.derive("DynamicPermissionSet").draw do
            dynamic_permissions.each do |dp|
              permission dp.key, default: dp.default?
            end
          end
        end