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: outline.rb
    path of file: ./repos/hexapdf/lib/hexapdf/type
    
    the code of the file until where you have to start completion: # -*- encoding: utf-8; frozen_string_literal: true -*-
#
#--
# This file is part of HexaPDF.
#
# HexaPDF - A Versatile PDF Creation and Manipulation Library For Ruby
# Copyright (C) 2014-2024 Thomas Leitner
#
# HexaPDF is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License version 3 as
# published by the Free Software Foundation with the addition of the
# following perm
    
      def self_as_item
        @self_as_item ||= document.wrap(self, type: :XXOutlineItem)
      end

      # Makes sure the required values are set.
      def perform_validation
        super
        first = self[:First]
        last = self[:Last]
        if (first && !last) || (!first && last)
          yield('Outline dictionary is missing an endpoint reference', true)
          node, dir = first ? [first, :Next] : [last, :Prev]
          node = node[dir] while node[dir]
          self[dir == :Next ? :Last : :First] = node
        elsif !first && !last && self[:Count] && self[:Count] != 0
          yield('Outline dictionary key /Count set but no items exist', true)
          delete(:Count)
        end
      end