Skip to content

module Athena::Serializer::Model #

Used to denote a type that is (de)serializable.

This module can be used to make the compiler happy in some situations, it doesn't do anything on its own. You most likely want to use ASR::Serializable instead.

require "athena-serializer"

abstract struct BaseModel
  # `ASR::Model` is needed here to ensure typings are correct for the deserialization process.
  # Child types should still include `ASR::Serializable`.
  include ASR::Model
end

record ModelOne < BaseModel, id : Int32, name : String do
  include ASR::Serializable
end

record ModelTwo < BaseModel, id : Int32, name : String do
  include ASR::Serializable
end

record Unionable, type : BaseModel.class