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: published_page.rb
    path of file: ./repos/discourse/app/models
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class PublishedPage < ActiveRecord::Base
  belongs_to :topic

  validates_presence_of :slug
  validates_uniqueness_of :slug, :topic_id

  validate :slug_format
  def slug_format
    if slug !~ /\A[a-zA-Z\-\_0-9]+\z/
    
    
  def self.publish!(publisher, topic, slug, options = {})
    pp = nil

    results =
      transaction do
        pp = find_or_initialize_by(topic: topic)
        pp.slug = slug.strip
        pp.public = options[:public] || false

        if pp.save
          StaffActionLogger.new(publisher).log_published_page(topic.id, slug)
          [true, pp]
        end
      end