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

require_dependency "alchemy/page"

module Alchemy
  class Page < Base
    
      def publish!(public_on:)
        Page.transaction do
          PageMutex.with_lock!(@page) do
            version = public_version(public_on)
            DeleteElements.new(version.elements).call

            repository = page.draft_version.element_repository
            ActiveRecord::Base.no_touching do
              Element.acts_as_list_no_update do
                repository.visible.not_nested.each.with_index(1) do |element, position|
                  Alchemy::DuplicateElement.new(element, repository: repository).call(
                    page_version_id: version.id,
                    position: position
                  )
                end
              end
            end
            page.update(published_at: public_on)
          end
        end

        Alchemy.publish_targets.each { |p| p.perform_later(page) }
      end