struct
Amber::Configuration::SectionField
- Amber::Configuration::SectionField
- Struct
- Value
- Object
Overview
Describes one field that YAML::Serializable reads for a registered
section type: its YAML key, what kind of value it holds, and, for a
nested section, that section's own fields.
The AMBER_* override pass uses it to name variables, to reach fields
that are nil or missing from the loaded YAML, and to turn each variable
into a value of the field's type. The credentials reader uses it to read
only the files a section declares. :nodoc:
Defined in:
amber/configuration/section_field.crConstructors
Class Method Summary
-
.list_for(type : T.class, list_of_enclosing_types : Array(String) = [] of String) : Array(SectionField) forall T
Lists the fields
YAML::Serializablereads for type, honoring@[YAML::Field(key: ...)]renames and skipping ignored fields. -
.yaml_of(instance : T) : String forall T
Writes instance as a YAML mapping of the fields
YAML::Serializablereads for its type, including fields markedignore_serialize, so a section rebuilt from this YAML keeps the values instance holds.
Instance Method Summary
-
#entry_kind : Kind
For a
Hashfield, the kind of each value it holds. - #key : String
- #list_of_fields : Array(SectionField)
- #value_kind : Kind
Constructor Detail
Class Method Detail
Lists the fields YAML::Serializable reads for type, honoring
@[YAML::Field(key: ...)] renames and skipping ignored fields.
list_of_enclosing_types names the section types already being listed on the way down, so a section type nested inside itself is listed once along each path and listing ends.
Writes instance as a YAML mapping of the fields YAML::Serializable
reads for its type, including fields marked ignore_serialize, so a
section rebuilt from this YAML keeps the values instance holds.
Nested sections are written the same way, and a nil value is written
as an explicit null.
A field is written only when Amber knows how without asking the type to
serialize: its value is a String, Bool, integer, float, Time or
enum, an Array or Hash of the first four, or a nested
YAML::Serializable section; or its converter is a type that defines
its own to_yaml. Any other field is left out, and a section rebuilt
from this YAML takes that field's declared default. So registering a type
never requires it, or its converters, to be writable as YAML.
The writer is typed to T, so it never dispatches over every
YAML::Serializable type in the program.