annotation Athena::Serializer::Annotations::PostDeserialize

Overview

Defines a callback method(s) that are ran directly after the object has been deserialized.

Example

record Example, name : String, first_name : String?, last_name : String? do
  include ASR::Serializable

  @[ASRA::PostDeserialize]
  private def split_name : Nil
    @first_name, @last_name = @name.split(' ')
  end
end

obj = ASR.serializer.deserialize Example, %({"name":"Jon Snow"}), :json

obj.name       # => Jon Snow
obj.first_name # => Jon
obj.last_name  # => Snow

Defined in:

annotations.cr