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

module Thredded
  class PostModerationRecord < ActiveRecord::Base
    include Thredded::ModerationState
    enum previous_moderation_state: moderation_states, _prefix: :previous
    validates :previous_moderation_state, presence: tr
    
    def self.record!(moderator:, post:, previous_moderation_state:, moderation_state:)
      create!(
        previous_moderation_state: previous_moderation_state,
        moderation_state:          moderation_state,
        moderator:                 moderator,
        post:                      post,
        post_content:              post.content,
        post_user:                 post.user,
        post_user_name:            post.user.try(:thredded_display_name),
        messageboard_id:           post.messageboard_id,
      )
    end