Skip to content

annotation Athena::Serializer::Annotations::ReadOnly #

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

NOTE: The property must be nilable, or have a default value.