Skip to content

struct Athena::Serializer::ExclusionStrategies::Version
inherits Struct #

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

Athena::Serializer::ExclusionStrategies::ExclusionStrategyInterface

Constructors#

.new(version : SemanticVersion)#

View source

Methods#

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

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

View source

#version : SemanticVersion#

View source