l0.DependencyControl.ConfigView¶
ConfigView ¶
A view into a hive (nested path) of a ConfigHandler's JSON config file. Holds the defaults-fallthrough machinery and exposes @c / @config / @userConfig. Multiple views on the same file are coordinated through their shared ConfigHandler.
Constructor ¶
Creates a view into a hive of the given ConfigHandler.
| param | type | description |
|---|---|---|
| configHandler | ConfigHandler|nil |
Backing handler, or nil for an in-memory (orphan) view. |
| hivePath | string|string[] |
The hive (nested key path) this view targets. |
| defaults? | table |
Default values for the hive. |
Instance methods¶
delete ¶
Removes this view's hive from the config file.
| param | type | description |
|---|---|---|
| waitLockTime? | number |
Seconds to wait for the config lock. |
Returns:
successboolean?errstring?
import ¶
Copies values from a table or ConfigView into this view's user config.
| param | type | description |
|---|---|---|
| tbl? | table|ConfigView |
Source values. |
| keys? | string[] |
Restrict the copy to these keys. |
| updateOnly? | boolean |
Only overwrite keys already present in this view. |
| skipSameLengthTables? | boolean |
Skip array values whose length matches the existing one. |
Returns:
changesMadeboolean
isOverlappingView ¶
Returns whether this view's hive overlaps with another view on the same handler.
| param | type | description |
|---|---|---|
| otherView | ConfigView |
Returns:
overlappingboolean? — nil when the views belong to different handlers.errstring?
load ¶
Reloads only this view's hive from the config file.
| param | type | description |
|---|---|---|
| waitLockTime? | number |
Seconds to wait for the config lock. |
Returns:
successboolean?errstring?
refresh ¶
Refreshes this view's userConfig from the handler's in-memory config.
Returns:
successboolean?errstring?
save ¶
Writes this view's hive to the config file.
| param | type | description |
|---|---|---|
| waitLockTime? | number |
Seconds to wait for the config lock. |
Returns:
successboolean?errstring?
write ¶
Deprecated — Use
save. Retained as an alias for callers written against DepCtrl < 0.7.
| param | type | description |
|---|---|---|
| waitLockTime? | number |
Seconds to wait for the config lock. |
Returns:
successboolean?errstring?
setFile ¶
Attaches this view to a different config file, without loading it (the caller loads separately).
| param | type | description |
|---|---|---|
| filePath | string |
Full path to the config file. |
Returns:
successboolean?errstring?
unsetFile ¶
Detaches this view from its config file, reverting to an in-memory (orphan) state.
Returns:
successboolean
getSectionHandler ¶
Returns a ConfigView for another hive of the same config file, sharing this view's handler.
| param | type | description |
|---|---|---|
| hivePath | string|string[] |
The hive path within the config file (from the file root, not relative to this view). |
| defaults? | table |
Default values for the returned view's hive. |
| noLoad? | boolean |
Skip loading the returned view (the caller loads it separately). |
Returns:
viewConfigView?errstring?
Class methods¶
get ¶
Returns a ConfigView for the given file and hive path, creating a handler if needed.
| param | type | description |
|---|---|---|
| filePath | string|boolean |
Config file path, or false for an in-memory (orphan) view. |
| hivePath | string|string[] |
The hive (nested key path) this view targets. |
| defaults? | table |
Default values for the hive. |
| logger? | Logger | |
| noLoad? | boolean |
Don't load the file immediately (default false). |
| schemaOpts? | { schemaId: string, migrate: fun(config: table, current?: string, target: string): boolean } |
Schema id/migration for the backing handler (see ConfigHandler.get); applied only when the handler is first created for this file. |
Returns:
viewConfigView?errstring?