annotation Athena::Serializer::Annotations::ReadOnly

Overview

Indicates that a property is read-only and cannot be set during deserialization.

Example

class Example
  include ASR::Serializable

  property name : String

  @[ASRA::ReadOnly]
  property password : String?
end

obj = ASR.serializer.deserialize Example, %({"name":"Fred","password":"password1"}), :json

obj.name     # => "Fred"
obj.password # => nil

!!!warning The property must be nilable, or have a default value.

Defined in:

annotations.cr