class TagVersionRecorder < VersionRecorder
  def self.record! tag:, event_type:, created_by_user:
    new(tag:, event_type:, created_by_user:).record!
  end

  def initialize tag:, event_type:, created_by_user:
    super(record: tag, event_type:, created_by_user:)
  end

  private

  def version_class = TagVersion
  def version_association = :tag_versions
  def record_key = :tag

  def snapshot_attributes
    { name: @record.name,
      category: @record.category,
      deprecated_at: @record.deprecated_at,
      aliases: @record.snapshot_aliases.join(' '),
      parent_tag_ids: @record.snapshot_parent_tag_ids.join(' ') }
  end
end
