annotation Athena::Serializer::Annotations::PostSerialize
Overview
Defines a callback method that is executed directly after the object has been serialized.
Example
@[ASRA::ExclusionPolicy(:all)]
class Example
include ASR::Serializable
def initialize; end
@[ASRA::Expose]
@name : String?
property first_name : String = "Jon"
property last_name : String = "Snow"
@[ASRA::PreSerialize]
private def pre_serialize : Nil
@name = "#{first_name} #{last_name}"
end
@[ASRA::PostSerialize]
private def post_serialize : Nil
@name = nil
end
end
ASR.serializer.serialize Example.new, :json # => {"name":"Jon Snow"}