annotation
RemiLib::RSConf::Field
Overview
Annotates a field in a class or struct to provide additional options when (de)serializing RSConf data.
Possible options are:
- ignore: if
trueskip this field in serialization and deserialization (by default false) - neverSerialize: If truthy, skip this field in serialization (default:
false). The value can be any Crystal expression and is evaluated at runtime. - neverDeserialize: if
trueskip this field in deserialization (by default false) - key: the value of the key in the RSConf object (by default the name of the instance variable)
- root: assume the value is inside an RSConf object with a given key
(see
Object.fromRSConf(stringOrIO, root)) - converter: specify an alternate type for parsing and generation. The
converter must define
fromRsconf(RemiLib::RSConf::RSValue)andtoRsconf(value, RemiLib::RSConf::RSValue). Examples of converters are aTime::Formatinstance andTime::EpochConverterforTime. - presence: if
true, a@{{key}}Presentinstance variable and a#getter?with the same name will be generated when the key was present (even if it has anullvalue),falseby default - emitNull: if
true, emits anullvalue for nilable property (by default nulls are not emitted) - blanksBefore: the number of blank lines to print before this field is
written. This occurs after any
Serializable#beforeToRsconfmethod is called, and before any comment is written. Default is 0. - blanksAfter: the number of blank lines to print after this field is
written. This occurs before any
Serializable#afterToRsconfmethod is called, and (if usingRemiLib::RSConf::Serializable::Unmapped), before any unmapped fields are written. Default is 0. - commentBefore: A comment string to write before the field is written.
This occurs after any
Serializable#beforeToRsconfmethod is called. This cannot be used together with the commentFnBefore property. - commentFnBefore: A function that must return a string. This will be
called before the field is written, and its return value will be written
as a comment. This occurs after any
Serializable#beforeToRsconfmethod is called. This cannot be used together with the commentBefore property. - commentIsBlock: When
true, then the commentBefore or commentFnBefore field is written usingRemiLib::RSConf::Builder#writeBlockComment. Default isfalse.