struct Athena::Serializer::ExclusionStrategies::Version

Overview

Serialize properties based on a SemanticVersion string.

It is enabled by default when using ASR::Context#version=.

class Example
  include ASR::Serializable

  def initialize; end

  @[ASRA::Until("1.0.0")]
  property name : String = "Legacy Name"

  @[ASRA::Since("1.1.0")]
  property name2 : String = "New Name"
end

obj = Example.new

ASR.serializer.serialize obj, :json, ASR::SerializationContext.new.version = "0.30.0" # => {"name":"Legacy Name"}
ASR.serializer.serialize obj, :json, ASR::SerializationContext.new.version = "1.2.0"  # => {"name2":"New Name"}

Included Modules

Defined in:

Constructors

Instance Method Summary

Instance methods inherited from module Athena::Serializer::ExclusionStrategies::ExclusionStrategyInterface

skip_property?(metadata : ASR::PropertyMetadataBase, context : ASR::Context) : Bool skip_property?

Constructor Detail

def self.new(version : SemanticVersion) #

Instance Method Detail

def skip_property?(metadata : ASR::PropertyMetadataBase, context : ASR::Context) : Bool #

Returns true if a property should NOT be (de)serialized.


def version : SemanticVersion #