struct Athena::Serializer::ExclusionStrategies::Version
- Athena::Serializer::ExclusionStrategies::Version
- Struct
- Value
- Object
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:
exclusion_strategies/version.crConstructors
Instance Method Summary
-
#skip_property?(metadata : ASR::PropertyMetadataBase, context : ASR::Context) : Bool
Returns
true
if a property should NOT be (de)serialized. - #version : SemanticVersion
Instance methods inherited from module Athena::Serializer::ExclusionStrategies::ExclusionStrategyInterface
skip_property?(metadata : ASR::PropertyMetadataBase, context : ASR::Context) : Bool
skip_property?
Constructor Detail
Instance Method Detail
Returns true
if a property should NOT be (de)serialized.