class

Kozai::Settings::Store

Inherits Reference < Object

The settings written from the interface, and the file holding them.

Constructors

load(path : String) : Store

Reads the file, or an empty store if there is none.

A file that cannot be parsed is reported and ignored rather than fatal: this file is written by the program, so a broken one means something else damaged it, and refusing to start over it would leave the operator with no interface to fix it from.

Source
new(path : String, values : Hash(String, String) = {} of String => String)
Source

Instance methods

apply(config : Config) : Config

Applies these values on top of config.

NOTE: what was overwritten is noted here, before the write, and not asked for afterwards. The origin of a setting is whatever set it last, so once this has run every one of them reads <settings page> and the environment variable underneath is gone. Reconstructing it later is not possible; recording it now is one line.

Source
candidate(changes : Hash(String, String)) : Store

A copy of this store with changes applied, for trying before buying.

Whether a configuration is usable cannot be decided field by field: a transponder path is a valid string and a missing file, a latitude is a valid number and the geometry may still refuse it. So the candidate is built here, everything is constructed from it, and only a candidate that survives that is written.

Source
empty?
Source
path

Where the file lives.

Source
render

The file's contents.

Source
save

Writes the file.

NOTE: written through a temporary and renamed, the same way the element cache is. A station losing power mid-write should come back with the old settings rather than with half a file it cannot parse โ€” and this file is how the operator would fix that, so it is the worst one to lose.

Source
set(qualified : String, raw : String) : Nil

Sets a value, after checking it.

NOTE: empty is handled before validation, not after. An empty field means "stop overriding this", putting the configuration file and the environment back in charge. Validating first instead refuses the whole save with "Altitude must be a number" โ€” for a field the operator never filled in and never meant to, on a form that submits all of them. That is not a hypothetical: it is what the page did the first time it was used.

Source
shadowing

Settings here that cover an environment variable.

NOTE: this is what keeps the arrangement honest. A value written from the interface outranks docker-compose.yml, which is what makes the page usable on a station configured entirely through the environment โ€” and would otherwise leave somebody editing a compose file that does nothing. Reported on the way up and through the API, never inferred.

Source
values

The values, by section.key.

Source