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: permission_name.rb
    path of file: ./repos/foreman/app/models/concerns
    
    the code of the file until where you have to start completion: module PermissionName
  extend ActiveSupport::Concern

  def permission_name(acti
    
    def find_permission_name(action)
      type = Permission.resource_name(self)
      permissions = Permission.where(:resource_type => type).where(["#{Permission.table_name}.name LIKE ?", "#{action}_%"])

      # some permissions are grouped for same resource, e.g. edit_comupute_resources and edit_compute_resources_vms, in such case we need to detect the right permission
      if permissions.size > 1
        permissions.detect { |p| p.name.end_with?(type.underscore.pluralize) }.try(:name)
      else
        permissions.first.try(:name)
      end